storj/web/satellite/tests/unit/navigationArea/EditProjectDropdown.spec.ts
VitaliiShpital 2668ec818e web/satellite: added ability to edit project name
WHAT:
added edit project dropdown to navigation side bar.
edit project details page implemented.
added ability to edit project name.
project details section removed from project dashboard.

WHY:
enable users to change their project name.

Change-Id: I36b6214ffe7adf4a12a1a09530ff1212e926aafe
2020-09-16 18:46:59 +03:00

70 lines
2.0 KiB
TypeScript

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
import { VNode } from 'vue';
import { DirectiveBinding } from 'vue/types/options';
import Vuex from 'vuex';
import EditProjectDropdown from '@/components/navigation/EditProjectDropdown.vue';
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
import { Project } from '@/types/projects';
import { createLocalVue, mount } from '@vue/test-utils';
import { ProjectsApiMock } from '../mock/api/projects';
const localVue = createLocalVue();
const projectsApi = new ProjectsApiMock();
const projectsModule = makeProjectsModule(projectsApi);
const store = new Vuex.Store({ modules: { projectsModule }});
const project = new Project('id', 'test', 'test', 'test', 'ownedId', false);
let clickOutsideEvent: EventListener;
localVue.directive('cli' +
'ck-outside', {
bind: function (el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
clickOutsideEvent = function(event: Event): void {
if (el === event.target) {
return;
}
if (vnode.context) {
vnode.context[binding.expression](event);
}
};
document.body.addEventListener('click', clickOutsideEvent);
},
unbind: function(): void {
document.body.removeEventListener('click', clickOutsideEvent);
},
});
localVue.use(Vuex);
store.commit(PROJECTS_MUTATIONS.ADD, project);
store.commit(PROJECTS_MUTATIONS.SELECT_PROJECT, project.id);
describe('EditProjectDropdown', () => {
it('renders correctly', (): void => {
const wrapper = mount(EditProjectDropdown, {
store,
localVue,
});
expect(wrapper).toMatchSnapshot();
});
it('dropdown opens correctly', async (): Promise<void> => {
const wrapper = mount(EditProjectDropdown, {
store,
localVue,
});
await wrapper.find('.edit-project__selection-area').trigger('click');
expect(wrapper).toMatchSnapshot();
});
});