Commit 5d1251be authored by Fatih Acet's avatar Fatih Acet

Merge branch 'upgrade-bootstrap-vue/user-popover-spec' into 'master'

Prepare user popover spec for BootstrapVue upgrade

See merge request gitlab-org/gitlab!20553
parents 29e7ae71 75e5be77
import UserPopover from '~/vue_shared/components/user_popover/user_popover.vue'; import UserPopover from '~/vue_shared/components/user_popover/user_popover.vue';
import { mount } from '@vue/test-utils'; import { GlSkeletonLoading } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
import { shallowMount } from '@vue/test-utils';
const DEFAULT_PROPS = { const DEFAULT_PROPS = {
loaded: true, loaded: true,
...@@ -29,7 +31,7 @@ describe('User Popover Component', () => { ...@@ -29,7 +31,7 @@ describe('User Popover Component', () => {
describe('Empty', () => { describe('Empty', () => {
beforeEach(() => { beforeEach(() => {
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
user: { user: {
...@@ -41,18 +43,19 @@ describe('User Popover Component', () => { ...@@ -41,18 +43,19 @@ describe('User Popover Component', () => {
status: null, status: null,
}, },
}, },
attachToDocument: true,
sync: false, sync: false,
}); });
}); });
it('should return skeleton loaders', () => { it('should return skeleton loaders', () => {
expect(wrapper.findAll('.animation-container').length).toBe(4); expect(wrapper.find(GlSkeletonLoading).exists()).toBe(true);
}); });
}); });
describe('basic data', () => { describe('basic data', () => {
it('should show basic fields', () => { it('should show basic fields', () => {
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -66,9 +69,9 @@ describe('User Popover Component', () => { ...@@ -66,9 +69,9 @@ describe('User Popover Component', () => {
}); });
it('shows icon for location', () => { it('shows icon for location', () => {
const iconEl = wrapper.find('.js-location svg'); const iconEl = wrapper.find(Icon);
expect(iconEl.find('use').element.getAttribute('xlink:href')).toContain('location'); expect(iconEl.props('name')).toEqual('location');
}); });
}); });
...@@ -77,7 +80,7 @@ describe('User Popover Component', () => { ...@@ -77,7 +80,7 @@ describe('User Popover Component', () => {
const testProps = Object.assign({}, DEFAULT_PROPS); const testProps = Object.assign({}, DEFAULT_PROPS);
testProps.user.bio = 'Engineer'; testProps.user.bio = 'Engineer';
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...testProps, ...testProps,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -92,7 +95,7 @@ describe('User Popover Component', () => { ...@@ -92,7 +95,7 @@ describe('User Popover Component', () => {
const testProps = Object.assign({}, DEFAULT_PROPS); const testProps = Object.assign({}, DEFAULT_PROPS);
testProps.user.organization = 'GitLab'; testProps.user.organization = 'GitLab';
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...testProps, ...testProps,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -108,7 +111,7 @@ describe('User Popover Component', () => { ...@@ -108,7 +111,7 @@ describe('User Popover Component', () => {
testProps.user.bio = 'Engineer'; testProps.user.bio = 'Engineer';
testProps.user.organization = 'GitLab'; testProps.user.organization = 'GitLab';
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -125,7 +128,7 @@ describe('User Popover Component', () => { ...@@ -125,7 +128,7 @@ describe('User Popover Component', () => {
testProps.user.bio = 'Manager & Team Lead'; testProps.user.bio = 'Manager & Team Lead';
testProps.user.organization = 'Me & my <funky> Company'; testProps.user.organization = 'Me & my <funky> Company';
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -138,15 +141,13 @@ describe('User Popover Component', () => { ...@@ -138,15 +141,13 @@ describe('User Popover Component', () => {
}); });
it('shows icon for bio', () => { it('shows icon for bio', () => {
const iconEl = wrapper.find('.js-bio svg'); expect(wrapper.findAll(Icon).filter(icon => icon.props('name') === 'profile').length).toEqual(
1,
expect(iconEl.find('use').element.getAttribute('xlink:href')).toContain('profile'); );
}); });
it('shows icon for organization', () => { it('shows icon for organization', () => {
const iconEl = wrapper.find('.js-organization svg'); expect(wrapper.findAll(Icon).filter(icon => icon.props('name') === 'work').length).toEqual(1);
expect(iconEl.find('use').element.getAttribute('xlink:href')).toContain('work');
}); });
}); });
...@@ -155,7 +156,7 @@ describe('User Popover Component', () => { ...@@ -155,7 +156,7 @@ describe('User Popover Component', () => {
const testProps = Object.assign({}, DEFAULT_PROPS); const testProps = Object.assign({}, DEFAULT_PROPS);
testProps.user.status = { message_html: 'Hello World' }; testProps.user.status = { message_html: 'Hello World' };
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
...@@ -170,7 +171,7 @@ describe('User Popover Component', () => { ...@@ -170,7 +171,7 @@ describe('User Popover Component', () => {
const testProps = Object.assign({}, DEFAULT_PROPS); const testProps = Object.assign({}, DEFAULT_PROPS);
testProps.user.status = { emoji: 'basketball_player', message_html: 'Hello World' }; testProps.user.status = { emoji: 'basketball_player', message_html: 'Hello World' };
wrapper = mount(UserPopover, { wrapper = shallowMount(UserPopover, {
propsData: { propsData: {
...DEFAULT_PROPS, ...DEFAULT_PROPS,
target: document.querySelector('.js-user-link'), target: document.querySelector('.js-user-link'),
......
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