debian-mirror-gitlab/spec/frontend/jobs/components/erased_block_spec.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { mount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui';
2018-11-20 20:47:30 +05:30
import { getTimeago } from '~/lib/utils/datetime_utility';
2020-01-01 13:55:28 +05:30
import ErasedBlock from '~/jobs/components/erased_block.vue';
2018-11-20 20:47:30 +05:30
describe('Erased block', () => {
2020-01-01 13:55:28 +05:30
let wrapper;
2018-11-20 20:47:30 +05:30
const erasedAt = '2016-11-07T11:11:16.525Z';
const timeago = getTimeago();
2020-01-01 13:55:28 +05:30
const formattedDate = timeago.format(erasedAt);
const createComponent = props => {
wrapper = mount(ErasedBlock, {
propsData: props,
sync: false,
attachToDocument: true,
});
};
2018-11-20 20:47:30 +05:30
afterEach(() => {
2020-01-01 13:55:28 +05:30
wrapper.destroy();
2018-11-20 20:47:30 +05:30
});
describe('with job erased by user', () => {
beforeEach(() => {
2020-01-01 13:55:28 +05:30
createComponent({
2018-12-05 23:21:45 +05:30
user: {
username: 'root',
web_url: 'gitlab.com/root',
},
2018-11-20 20:47:30 +05:30
erasedAt,
});
});
it('renders username and link', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.find(GlLink).attributes('href')).toEqual('gitlab.com/root');
2018-11-20 20:47:30 +05:30
2020-01-01 13:55:28 +05:30
expect(wrapper.text().trim()).toContain('Job has been erased by');
expect(wrapper.text().trim()).toContain('root');
2018-11-20 20:47:30 +05:30
});
it('renders erasedAt', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.text().trim()).toContain(formattedDate);
2018-11-20 20:47:30 +05:30
});
});
describe('with erased job', () => {
beforeEach(() => {
2020-01-01 13:55:28 +05:30
createComponent({
2018-11-20 20:47:30 +05:30
erasedAt,
});
});
it('renders username and link', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.text().trim()).toContain('Job has been erased');
2018-11-20 20:47:30 +05:30
});
it('renders erasedAt', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.text().trim()).toContain(formattedDate);
2018-11-20 20:47:30 +05:30
});
});
});