diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /spec/frontend/organizations/show/components/association_count_card_spec.js | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'spec/frontend/organizations/show/components/association_count_card_spec.js')
-rw-r--r-- | spec/frontend/organizations/show/components/association_count_card_spec.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/frontend/organizations/show/components/association_count_card_spec.js b/spec/frontend/organizations/show/components/association_count_card_spec.js new file mode 100644 index 00000000000..752a02110b6 --- /dev/null +++ b/spec/frontend/organizations/show/components/association_count_card_spec.js @@ -0,0 +1,48 @@ +import { GlCard, GlLink } from '@gitlab/ui'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import AssociationCountCard from '~/organizations/show/components/association_count_card.vue'; + +describe('AssociationCountCard', () => { + let wrapper; + + const defaultPropsData = { + title: 'Groups', + iconName: 'group', + count: 1050, + linkHref: '/-/organizations/default/groups_and_projects?display=groups', + }; + + const createComponent = ({ propsData = {} } = {}) => { + wrapper = shallowMountExtended(AssociationCountCard, { + propsData: { ...defaultPropsData, ...propsData }, + }); + }; + + const findCard = () => wrapper.findComponent(GlCard); + const findLink = () => findCard().findComponent(GlLink); + + it('renders card with title, link and count', () => { + createComponent(); + + const card = findCard(); + const link = findLink(); + + expect(card.text()).toContain(defaultPropsData.title); + expect(card.text()).toContain('1k'); + expect(link.text()).toBe('View all'); + expect(link.attributes('href')).toBe(defaultPropsData.linkHref); + }); + + describe('when `linkText` prop is set', () => { + const linkText = 'Manage'; + beforeEach(() => { + createComponent({ + propsData: { linkText }, + }); + }); + + it('sets link text', () => { + expect(findLink().text()).toBe(linkText); + }); + }); +}); |