Commit 99f88012 authored by Sheldon Led's avatar Sheldon Led

Use `it.each` in the new test as per MR suggestion

parent d993263a
......@@ -176,27 +176,31 @@ describe('Subscription Seats', () => {
});
});
describe('member badges', () => {
it('shows the correct badge based on membership_type', () => {
describe('members avatar', () => {
it('shows the correct avatarLinks length', () => {
const avatarLinks = findTable().findAllComponents(GlAvatarLink);
expect(avatarLinks.length).toBe(4);
avatarLinks.wrappers.forEach((avatarLinkWrapper) => {
const currentMember = mockTableItems.find(
(item) => item.user.name === avatarLinkWrapper.attributes().alt,
);
const currentMembershipType = currentMember.user.membership_type;
const membershipTypesWithBadge = ['group_invite', 'project_invite'];
if (membershipTypesWithBadge.includes(currentMembershipType)) {
const badgeText = (
currentMembershipType.charAt(0).toUpperCase() + currentMembershipType.slice(1)
).replace('_', ' ');
expect(avatarLinkWrapper.find(GlBadge).text()).toBe(badgeText);
}
});
});
it.each(['group_invite', 'project_invite'])(
'shows the correct badge for membership_type %s',
(membershipType) => {
const avatarLinks = findTable().findAllComponents(GlAvatarLink);
const badgeText = (
membershipType.charAt(0).toUpperCase() + membershipType.slice(1)
).replace('_', ' ');
avatarLinks.wrappers.forEach((avatarLinkWrapper) => {
const currentMember = mockTableItems.find(
(item) => item.user.name === avatarLinkWrapper.attributes().alt,
);
if (membershipType === currentMember.user.membership_type) {
expect(avatarLinkWrapper.find(GlBadge).text()).toBe(badgeText);
}
});
},
);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment