debian-mirror-gitlab/spec/frontend/members/components/table/member_avatar_spec.js
2021-02-22 17:27:13 +05:30

39 lines
1.5 KiB
JavaScript

import { shallowMount } from '@vue/test-utils';
import { MEMBER_TYPES } from '~/members/constants';
import { member as memberMock, group, invite, accessRequest } from '../../mock_data';
import MemberAvatar from '~/members/components/table/member_avatar.vue';
import UserAvatar from '~/members/components/avatars/user_avatar.vue';
import GroupAvatar from '~/members/components/avatars/group_avatar.vue';
import InviteAvatar from '~/members/components/avatars/invite_avatar.vue';
describe('MemberList', () => {
let wrapper;
const createComponent = propsData => {
wrapper = shallowMount(MemberAvatar, {
propsData: {
isCurrentUser: false,
...propsData,
},
});
};
afterEach(() => {
wrapper.destroy();
});
test.each`
memberType | member | expectedComponent | expectedComponentName
${MEMBER_TYPES.user} | ${memberMock} | ${UserAvatar} | ${'UserAvatar'}
${MEMBER_TYPES.group} | ${group} | ${GroupAvatar} | ${'GroupAvatar'}
${MEMBER_TYPES.invite} | ${invite} | ${InviteAvatar} | ${'InviteAvatar'}
${MEMBER_TYPES.accessRequest} | ${accessRequest} | ${UserAvatar} | ${'UserAvatar'}
`(
'renders $expectedComponentName when `memberType` is $memberType',
({ memberType, member, expectedComponent }) => {
createComponent({ memberType, member });
expect(wrapper.find(expectedComponent).exists()).toBe(true);
},
);
});