b23b3e02e6
This change updates VButton with composition API, updates .eslintrc.js to ignore resulting import errors, and fix resulting test failures. see: https://github.com/storj/storj/issues/5114 Change-Id: Iaf9e8323333c797936d3acb38dd32f6e27d1ed08
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
import Vuex from 'vuex';
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import { ProjectsApiMock } from '../mock/api/projects';
|
|
|
|
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
|
import { Project, ProjectLimits } from '@/types/projects';
|
|
import { NotificatorPlugin } from '@/utils/plugins/notificator';
|
|
import { makeNotificationsModule } from '@/store/modules/notifications';
|
|
|
|
import EditProjectDetails from '@/components/project/EditProjectDetails.vue';
|
|
|
|
const localVue = createLocalVue();
|
|
localVue.use(Vuex);
|
|
|
|
const projectLimits = new ProjectLimits(1000, 100, 1000, 100);
|
|
const projectsApi = new ProjectsApiMock();
|
|
projectsApi.setMockLimits(projectLimits);
|
|
const projectsModule = makeProjectsModule(projectsApi);
|
|
const notificationsModule = makeNotificationsModule();
|
|
|
|
const store = new Vuex.Store({
|
|
modules: {
|
|
projectsModule,
|
|
notificationsModule,
|
|
usersModule: {
|
|
state: {
|
|
user: { paidTier: false },
|
|
},
|
|
},
|
|
} });
|
|
|
|
localVue.use(new NotificatorPlugin(store));
|
|
|
|
const project = new Project('id', 'test', 'test', 'test', 'ownedId', false);
|
|
|
|
describe('EditProjectDetails.vue', () => {
|
|
it('renders correctly', (): void => {
|
|
store.commit(PROJECTS_MUTATIONS.ADD, project);
|
|
store.commit(PROJECTS_MUTATIONS.SELECT_PROJECT, project.id);
|
|
store.commit(PROJECTS_MUTATIONS.SET_LIMITS, projectLimits);
|
|
|
|
const wrapper = shallowMount<EditProjectDetails>(EditProjectDetails, {
|
|
store,
|
|
localVue,
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('editing name works correctly', async (): Promise<void> => {
|
|
const wrapper = shallowMount<EditProjectDetails>(EditProjectDetails, {
|
|
store,
|
|
localVue,
|
|
});
|
|
|
|
await wrapper.vm.toggleNameEditing();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
const newName = 'new name';
|
|
|
|
wrapper.vm.$data.nameValue = newName;
|
|
await wrapper.vm.onSaveNameButtonClick();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
await expect(store.getters.selectedProject.name).toMatch(newName);
|
|
});
|
|
|
|
it('editing description works correctly', async (): Promise<void> => {
|
|
const wrapper = shallowMount<EditProjectDetails>(EditProjectDetails, {
|
|
store,
|
|
localVue,
|
|
});
|
|
|
|
await wrapper.vm.toggleDescriptionEditing();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
const newDescription = 'new description';
|
|
|
|
wrapper.vm.$data.descriptionValue = newDescription;
|
|
await wrapper.vm.onSaveDescriptionButtonClick();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
await expect(store.getters.selectedProject.description).toMatch(newDescription);
|
|
});
|
|
});
|