diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 17:36:54 +0300 |
commit | f61bb2a16a514b71bf33aabbbb999d6732016a24 (patch) | |
tree | 9548caa89e60b4f40b99bbd1dac030420b812aa8 /spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js | |
parent | 35fc54e5d261f8898e390aea7c2f5ec5fdf0539d (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc42
Diffstat (limited to 'spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js')
-rw-r--r-- | spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js new file mode 100644 index 00000000000..db6e175b054 --- /dev/null +++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/infrastructure_title_spec.js @@ -0,0 +1,75 @@ +import { shallowMount } from '@vue/test-utils'; +import component from '~/packages_and_registries/infrastructure_registry/components/infrastructure_title.vue'; +import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue'; +import TitleArea from '~/vue_shared/components/registry/title_area.vue'; + +describe('Infrastructure Title', () => { + let wrapper; + let store; + + const findTitleArea = () => wrapper.find(TitleArea); + const findMetadataItem = () => wrapper.find(MetadataItem); + + const mountComponent = (propsData = { helpUrl: 'foo' }) => { + wrapper = shallowMount(component, { + store, + propsData, + stubs: { + TitleArea, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('title area', () => { + it('exists', () => { + mountComponent(); + + expect(findTitleArea().exists()).toBe(true); + }); + + it('has the correct props', () => { + mountComponent(); + + expect(findTitleArea().props()).toMatchObject({ + title: 'Infrastructure Registry', + infoMessages: [ + { + text: 'Publish and share your modules. %{docLinkStart}More information%{docLinkEnd}', + link: 'foo', + }, + ], + }); + }); + }); + + describe.each` + count | exist | text + ${null} | ${false} | ${''} + ${undefined} | ${false} | ${''} + ${0} | ${true} | ${'0 Modules'} + ${1} | ${true} | ${'1 Module'} + ${2} | ${true} | ${'2 Modules'} + `('when count is $count metadata item', ({ count, exist, text }) => { + beforeEach(() => { + mountComponent({ count, helpUrl: 'foo' }); + }); + + it(`is ${exist} that it exists`, () => { + expect(findMetadataItem().exists()).toBe(exist); + }); + + if (exist) { + it('has the correct props', () => { + expect(findMetadataItem().props()).toMatchObject({ + icon: 'infrastructure-registry', + text, + }); + }); + } + }); +}); |