2019-08-19 12:20:38 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-10-22 12:12:49 +01:00
|
|
|
import Vuex from 'vuex';
|
2022-11-14 10:57:31 +00:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-10-22 12:12:49 +01:00
|
|
|
import { ProjectsApiGql } from '@/api/projects';
|
|
|
|
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
2019-08-20 13:57:43 +01:00
|
|
|
import { ProjectMember } from '@/types/projectMembers';
|
2019-10-22 12:12:49 +01:00
|
|
|
import { Project } from '@/types/projects';
|
2022-09-08 15:11:09 +01:00
|
|
|
|
|
|
|
import ProjectMemberListItem from '@/components/team/ProjectMemberListItem.vue';
|
2019-10-22 12:12:49 +01:00
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
|
|
|
|
localVue.use(Vuex);
|
2019-08-19 12:20:38 +01:00
|
|
|
|
|
|
|
describe('', () => {
|
2019-10-22 12:12:49 +01:00
|
|
|
const pApi = new ProjectsApiGql();
|
|
|
|
const projectsModule = makeProjectsModule(pApi);
|
2020-09-28 14:44:01 +01:00
|
|
|
const data = new Date(0);
|
|
|
|
const member: ProjectMember = new ProjectMember('testFullName', 'testShortName', 'test@example.com', data, '1');
|
2019-10-22 12:12:49 +01:00
|
|
|
const project: Project = new Project('testId', 'testName', 'testDescr', 'testDate', '1');
|
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
const store = new Vuex.Store({ modules: { projectsModule } });
|
2019-10-22 12:12:49 +01:00
|
|
|
|
|
|
|
store.commit(PROJECTS_MUTATIONS.SET_PROJECTS, [project]);
|
|
|
|
store.commit(PROJECTS_MUTATIONS.SELECT_PROJECT, 'testId');
|
2019-08-19 12:20:38 +01:00
|
|
|
|
2019-10-22 12:12:49 +01:00
|
|
|
it('should render correctly', function () {
|
2022-11-14 10:57:31 +00:00
|
|
|
const wrapper = shallowMount(ProjectMemberListItem, {
|
2019-10-22 12:12:49 +01:00
|
|
|
store,
|
|
|
|
localVue,
|
2019-08-19 12:20:38 +01:00
|
|
|
propsData: {
|
2019-09-13 15:58:18 +01:00
|
|
|
itemData: member,
|
|
|
|
},
|
2019-08-19 12:20:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
2019-10-22 12:12:49 +01:00
|
|
|
expect(store.getters.selectedProject.ownerId).toBe(member.user.id);
|
2022-07-22 18:09:30 +01:00
|
|
|
expect(wrapper.findAll('.owner').length).toBe(1);
|
2019-08-19 12:20:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render correctly with item row highlighted', function () {
|
|
|
|
member.isSelected = true;
|
|
|
|
|
2022-11-14 10:57:31 +00:00
|
|
|
const wrapper = shallowMount(ProjectMemberListItem, {
|
2019-10-22 12:12:49 +01:00
|
|
|
store,
|
|
|
|
localVue,
|
2019-08-19 12:20:38 +01:00
|
|
|
propsData: {
|
2019-09-13 15:58:18 +01:00
|
|
|
itemData: member,
|
|
|
|
},
|
2019-08-19 12:20:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|