diff options
Diffstat (limited to 'spec/frontend/vue_mr_widget/components/artifacts_list_spec.js')
-rw-r--r-- | spec/frontend/vue_mr_widget/components/artifacts_list_spec.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js b/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js new file mode 100644 index 00000000000..8c805faf574 --- /dev/null +++ b/spec/frontend/vue_mr_widget/components/artifacts_list_spec.js @@ -0,0 +1,61 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { GlLink } from '@gitlab/ui'; +import ArtifactsList from '~/vue_merge_request_widget/components/artifacts_list.vue'; +import { artifactsList } from './mock_data'; + +describe('Artifacts List', () => { + let wrapper; + const localVue = createLocalVue(); + + const data = { + artifacts: artifactsList, + }; + + const mountComponent = props => { + wrapper = shallowMount(localVue.extend(ArtifactsList), { + propsData: { + ...props, + }, + sync: false, + localVue, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + beforeEach(() => { + mountComponent(data); + }); + + it('renders list of artifacts', () => { + expect(wrapper.findAll('tbody tr').length).toEqual(data.artifacts.length); + }); + + it('renders link for the artifact', () => { + expect(wrapper.find(GlLink).attributes('href')).toEqual(data.artifacts[0].url); + }); + + it('renders artifact name', () => { + expect(wrapper.find(GlLink).text()).toEqual(data.artifacts[0].text); + }); + + it('renders job url', () => { + expect( + wrapper + .findAll(GlLink) + .at(1) + .attributes('href'), + ).toEqual(data.artifacts[0].job_path); + }); + + it('renders job name', () => { + expect( + wrapper + .findAll(GlLink) + .at(1) + .text(), + ).toEqual(data.artifacts[0].job_name); + }); +}); |