storj/web/satellite/tests/unit/projectMembers/ProjectMemberListItem.spec.ts
wilfredasomani 0eb2cc4511 web/satellite: update table component for project member page
This changes the project member page's table to match the new table design,
And updates the common table component fit this page's use case.

For: https://github.com/storj/storj/issues/4993

Change-Id: Ic7e2c4ceade9bbc98793760927a9243914f454d0
2022-07-28 12:57:05 +00:00

58 lines
1.8 KiB
TypeScript

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
import Vuex from 'vuex';
import ProjectMemberListItem from '@/components/team/ProjectMemberListItem.vue';
import { ProjectsApiGql } from '@/api/projects';
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
import { ProjectMember } from '@/types/projectMembers';
import { Project } from '@/types/projects';
import { createLocalVue, mount } from '@vue/test-utils';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('', () => {
const pApi = new ProjectsApiGql();
const projectsModule = makeProjectsModule(pApi);
const data = new Date(0);
const member: ProjectMember = new ProjectMember('testFullName', 'testShortName', 'test@example.com', data, '1');
const project: Project = new Project('testId', 'testName', 'testDescr', 'testDate', '1');
const store = new Vuex.Store({modules: { projectsModule }});
store.commit(PROJECTS_MUTATIONS.SET_PROJECTS, [project]);
store.commit(PROJECTS_MUTATIONS.SELECT_PROJECT, 'testId');
it('should render correctly', function () {
const wrapper = mount(ProjectMemberListItem, {
store,
localVue,
propsData: {
itemData: member,
},
});
expect(wrapper).toMatchSnapshot();
expect(store.getters.selectedProject.ownerId).toBe(member.user.id);
expect(wrapper.findAll('.owner').length).toBe(1);
});
it('should render correctly with item row highlighted', function () {
member.isSelected = true;
const wrapper = mount(ProjectMemberListItem, {
store,
localVue,
propsData: {
itemData: member,
},
});
expect(wrapper).toMatchSnapshot();
});
});