debian-mirror-gitlab/spec/frontend/jira_import/components/jira_import_progress_spec.js

75 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import { GlEmptyState } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import JiraImportProgress from '~/jira_import/components/jira_import_progress.vue';
2020-07-28 23:09:34 +05:30
import { illustration, issuesPath } from '../mock_data';
2020-05-24 23:13:21 +05:30
2020-04-22 19:07:51 +05:30
describe('JiraImportProgress', () => {
let wrapper;
2020-07-28 23:09:34 +05:30
const importProject = 'JIRAPROJECT';
2020-05-24 23:13:21 +05:30
const getGlEmptyStateProp = attribute => wrapper.find(GlEmptyState).props(attribute);
2020-04-22 19:07:51 +05:30
const getParagraphText = () => wrapper.find('p').text();
const mountComponent = ({ mountType = 'shallowMount' } = {}) => {
const mountFunction = mountType === 'shallowMount' ? shallowMount : mount;
return mountFunction(JiraImportProgress, {
propsData: {
2020-05-24 23:13:21 +05:30
illustration,
2020-04-22 19:07:51 +05:30
importInitiator: 'Jane Doe',
2020-05-24 23:13:21 +05:30
importProject,
2020-04-22 19:07:51 +05:30
importTime: '2020-04-08T12:17:25+00:00',
2020-05-24 23:13:21 +05:30
issuesPath,
2020-04-22 19:07:51 +05:30
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('empty state', () => {
beforeEach(() => {
wrapper = mountComponent();
});
it('contains illustration', () => {
2020-05-24 23:13:21 +05:30
expect(getGlEmptyStateProp('svgPath')).toBe(illustration);
2020-04-22 19:07:51 +05:30
});
it('contains a title', () => {
const title = 'Import in progress';
2020-05-24 23:13:21 +05:30
expect(getGlEmptyStateProp('title')).toBe(title);
2020-04-22 19:07:51 +05:30
});
it('contains button text', () => {
2020-05-24 23:13:21 +05:30
expect(getGlEmptyStateProp('primaryButtonText')).toBe('View issues');
2020-04-22 19:07:51 +05:30
});
it('contains button url', () => {
2020-05-24 23:13:21 +05:30
const expected = `${issuesPath}?search=${importProject}`;
expect(getGlEmptyStateProp('primaryButtonLink')).toBe(expected);
2020-04-22 19:07:51 +05:30
});
});
describe('description', () => {
beforeEach(() => {
wrapper = mountComponent({ mountType: 'mount' });
});
it('shows who initiated the import', () => {
expect(getParagraphText()).toContain('Import started by: Jane Doe');
});
it('shows the time of import', () => {
expect(getParagraphText()).toContain('Time of import: Apr 8, 2020 12:17pm GMT+0000');
});
it('shows the project key of the import', () => {
expect(getParagraphText()).toContain('Jira project: JIRAPROJECT');
});
});
});