2021-01-03 14:25:43 +05:30
|
|
|
import { mount, createWrapper } from '@vue/test-utils';
|
|
|
|
import { getByText as getByTextHelper } from '@testing-library/dom';
|
|
|
|
import { GlAvatarLink } from '@gitlab/ui';
|
2021-02-22 17:27:13 +05:30
|
|
|
import { group as member } from '../../mock_data';
|
|
|
|
import GroupAvatar from '~/members/components/avatars/group_avatar.vue';
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
describe('MemberList', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const group = member.sharedWithGroup;
|
|
|
|
|
|
|
|
const createComponent = (propsData = {}) => {
|
|
|
|
wrapper = mount(GroupAvatar, {
|
|
|
|
propsData: {
|
|
|
|
member,
|
|
|
|
...propsData,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const getByText = (text, options) =>
|
|
|
|
createWrapper(getByTextHelper(wrapper.element, text, options));
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link to group', () => {
|
|
|
|
const link = wrapper.find(GlAvatarLink);
|
|
|
|
|
|
|
|
expect(link.exists()).toBe(true);
|
|
|
|
expect(link.attributes('href')).toBe(group.webUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders group's full name", () => {
|
|
|
|
expect(getByText(group.fullName).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders group's avatar", () => {
|
|
|
|
expect(wrapper.find('img').attributes('src')).toBe(group.avatarUrl);
|
|
|
|
});
|
|
|
|
});
|