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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { GlLink } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import ErasedBlock from '~/jobs/components/erased_block.vue';
2021-03-11 19:13:27 +05:30
import { getTimeago } from '~/lib/utils/datetime_utility';
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);
2021-03-11 19:13:27 +05:30
const findLink = () => wrapper.find(GlLink);
2021-03-08 18:12:59 +05:30
const createComponent = (props) => {
2020-01-01 13:55:28 +05:30
wrapper = mount(ErasedBlock, {
propsData: props,
});
};
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', () => {
2021-03-11 19:13:27 +05:30
expect(findLink().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
});
});
});