diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-29 00:07:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-29 00:07:10 +0300 |
commit | a955f4024d40663f4b1affd74a346ffc96a92371 (patch) | |
tree | 7ed63c2c6451791b95cef89a49e33852b4c310ea /spec/frontend/vue_shared/components | |
parent | 0e08747b3d348b6c0effae19fe7050af327c05e2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components')
-rw-r--r-- | spec/frontend/vue_shared/components/help_page_link/help_page_link_spec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/help_page_link/help_page_link_spec.js b/spec/frontend/vue_shared/components/help_page_link/help_page_link_spec.js new file mode 100644 index 00000000000..5c17558b9cf --- /dev/null +++ b/spec/frontend/vue_shared/components/help_page_link/help_page_link_spec.js @@ -0,0 +1,51 @@ +import { shallowMount, Wrapper } from '@vue/test-utils'; // eslint-disable-line no-unused-vars +import { GlLink } from '@gitlab/ui'; +import HelpPageLink from '~/vue_shared/components/help_page_link/help_page_link.vue'; +import { helpPagePath } from '~/helpers/help_page_helper'; + +/** @type { Wrapper } */ +let wrapper; + +const createComponent = (props = {}, slots = {}) => { + wrapper = shallowMount(HelpPageLink, { + propsData: { + ...props, + }, + slots, + stubs: { + GlLink: true, + }, + }); +}; + +const findGlLink = () => wrapper.findComponent(GlLink); + +describe('HelpPageLink', () => { + it('renders a link', () => { + const href = 'user/usage_quotas'; + createComponent({ href }); + + const link = findGlLink(); + const expectedHref = helpPagePath(href, { anchor: null }); + expect(link.attributes().href).toBe(expectedHref); + }); + + it('adds the anchor', () => { + const href = 'user/usage_quotas'; + const anchor = 'namespace-storage-limit'; + createComponent({ href, anchor }); + + const link = findGlLink(); + const expectedHref = helpPagePath(href, { anchor }); + expect(link.attributes().href).toBe(expectedHref); + }); + + it('renders slot content', () => { + const href = 'user/usage_quotas'; + const slotContent = 'slot content'; + createComponent({ href }, { default: slotContent }); + + const link = findGlLink(); + expect(link.text()).toBe(slotContent); + }); +}); |