diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/frontend/jobs/components/job/erased_block_spec.js | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/frontend/jobs/components/job/erased_block_spec.js')
-rw-r--r-- | spec/frontend/jobs/components/job/erased_block_spec.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/frontend/jobs/components/job/erased_block_spec.js b/spec/frontend/jobs/components/job/erased_block_spec.js new file mode 100644 index 00000000000..c6aba01fa53 --- /dev/null +++ b/spec/frontend/jobs/components/job/erased_block_spec.js @@ -0,0 +1,63 @@ +import { GlLink } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; +import ErasedBlock from '~/jobs/components/job/erased_block.vue'; +import { getTimeago } from '~/lib/utils/datetime_utility'; + +describe('Erased block', () => { + let wrapper; + + const erasedAt = '2016-11-07T11:11:16.525Z'; + const timeago = getTimeago(); + const formattedDate = timeago.format(erasedAt); + + const findLink = () => wrapper.findComponent(GlLink); + + const createComponent = (props) => { + wrapper = mount(ErasedBlock, { + propsData: props, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('with job erased by user', () => { + beforeEach(() => { + createComponent({ + user: { + username: 'root', + web_url: 'gitlab.com/root', + }, + erasedAt, + }); + }); + + it('renders username and link', () => { + expect(findLink().attributes('href')).toEqual('gitlab.com/root'); + + expect(wrapper.text().trim()).toContain('Job has been erased by'); + expect(wrapper.text().trim()).toContain('root'); + }); + + it('renders erasedAt', () => { + expect(wrapper.text().trim()).toContain(formattedDate); + }); + }); + + describe('with erased job', () => { + beforeEach(() => { + createComponent({ + erasedAt, + }); + }); + + it('renders username and link', () => { + expect(wrapper.text().trim()).toContain('Job has been erased'); + }); + + it('renders erasedAt', () => { + expect(wrapper.text().trim()).toContain(formattedDate); + }); + }); +}); |