2019-03-01 16:41:16 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-02-03 04:08:42 -05:00
|
|
|
import MRPopover from '~/mr_popover/components/mr_popover.vue';
|
2020-01-02 10:07:40 -05:00
|
|
|
import CiIcon from '~/vue_shared/components/ci_icon.vue';
|
2019-03-01 16:41:16 -05:00
|
|
|
|
|
|
|
describe('MR Popover', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = shallowMount(MRPopover, {
|
|
|
|
propsData: {
|
|
|
|
target: document.createElement('a'),
|
|
|
|
projectPath: 'foo/bar',
|
|
|
|
mergeRequestIID: '1',
|
|
|
|
mergeRequestTitle: 'MR Title',
|
|
|
|
},
|
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
loading: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows skeleton-loader while apollo is loading', () => {
|
|
|
|
wrapper.vm.$apollo.loading = true;
|
|
|
|
|
2020-01-02 10:07:40 -05:00
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
2019-03-01 16:41:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('loaded state', () => {
|
|
|
|
it('matches the snapshot', () => {
|
|
|
|
wrapper.setData({
|
|
|
|
mergeRequest: {
|
|
|
|
state: 'opened',
|
|
|
|
createdAt: new Date(),
|
|
|
|
headPipeline: {
|
|
|
|
detailedStatus: {
|
|
|
|
group: 'success',
|
|
|
|
status: 'status_success',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-01-01 01:09:01 -05:00
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
2019-03-01 16:41:16 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show CI Icon if there is no pipeline data', () => {
|
|
|
|
wrapper.setData({
|
|
|
|
mergeRequest: {
|
|
|
|
state: 'opened',
|
|
|
|
headPipeline: null,
|
|
|
|
stateHumanName: 'Open',
|
|
|
|
title: 'Merge Request Title',
|
|
|
|
createdAt: new Date(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-01-01 01:09:01 -05:00
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
2020-08-28 08:10:37 -04:00
|
|
|
expect(wrapper.find(CiIcon).exists()).toBe(false);
|
2020-01-01 01:09:01 -05:00
|
|
|
});
|
2019-03-01 16:41:16 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|