Welcome to mirror list, hosted at ThFree Co, Russian Federation.

association_count_card_spec.js « components « show « organizations « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 752a02110b68518f5c1993224aac3c902f038f93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
    });
  });
});