diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/frontend/admin/users/components/user_avatar_spec.js | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/frontend/admin/users/components/user_avatar_spec.js')
-rw-r--r-- | spec/frontend/admin/users/components/user_avatar_spec.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend/admin/users/components/user_avatar_spec.js b/spec/frontend/admin/users/components/user_avatar_spec.js new file mode 100644 index 00000000000..ba4e83690d0 --- /dev/null +++ b/spec/frontend/admin/users/components/user_avatar_spec.js @@ -0,0 +1,63 @@ +import { GlAvatarLink, GlAvatarLabeled, GlBadge } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; + +import AdminUserAvatar from '~/admin/users/components/user_avatar.vue'; +import { users, paths } from '../mock_data'; + +describe('AdminUserAvatar component', () => { + let wrapper; + const user = users[0]; + const adminUserPath = paths.adminUser; + + const findAvatar = () => wrapper.find(GlAvatarLabeled); + const findAvatarLink = () => wrapper.find(GlAvatarLink); + const findAllBadges = () => wrapper.findAll(GlBadge); + + const initComponent = (props = {}) => { + wrapper = mount(AdminUserAvatar, { + propsData: { + user, + adminUserPath, + ...props, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('when initialized', () => { + beforeEach(() => { + initComponent(); + }); + + it("links to the user's admin path", () => { + expect(findAvatarLink().attributes()).toMatchObject({ + href: adminUserPath.replace('id', user.username), + 'data-user-id': user.id.toString(), + 'data-username': user.username, + }); + }); + + it("renders the user's name", () => { + expect(findAvatar().props('label')).toBe(user.name); + }); + + it("renders the user's email", () => { + expect(findAvatar().props('subLabel')).toBe(user.email); + }); + + it("renders the user's avatar image", () => { + expect(findAvatar().attributes('src')).toBe(user.avatarUrl); + }); + + it("renders the user's badges", () => { + findAllBadges().wrappers.forEach((badge, idx) => { + expect(badge.text()).toBe(user.badges[idx].text); + expect(badge.props('variant')).toBe(user.badges[idx].variant); + }); + }); + }); +}); |