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

runner_assigned_item_spec.js « components « runner « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5df2e04c3406fce3e857bc42d38729e76c0a18e7 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { GlAvatar, GlBadge } from '@gitlab/ui';
import { s__ } from '~/locale';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import RunnerAssignedItem from '~/ci/runner/components/runner_assigned_item.vue';
import { AVATAR_SHAPE_OPTION_RECT } from '~/vue_shared/constants';

const mockHref = '/group/project';
const mockName = 'Project';
const mockDescription = 'Project description';
const mockFullName = 'Group / Project';
const mockAvatarUrl = '/avatar.png';

describe('RunnerAssignedItem', () => {
  let wrapper;

  const findAvatar = () => wrapper.findByTestId('item-avatar');
  const findBadge = () => wrapper.findComponent(GlBadge);

  const createComponent = ({ props = {} } = {}) => {
    wrapper = shallowMountExtended(RunnerAssignedItem, {
      propsData: {
        href: mockHref,
        name: mockName,
        fullName: mockFullName,
        avatarUrl: mockAvatarUrl,
        description: mockDescription,
        ...props,
      },
    });
  };

  beforeEach(() => {
    createComponent();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('Shows an avatar', () => {
    const avatar = findAvatar();

    expect(avatar.attributes('href')).toBe(mockHref);
    expect(avatar.findComponent(GlAvatar).props()).toMatchObject({
      alt: mockName,
      entityName: mockName,
      src: mockAvatarUrl,
      shape: AVATAR_SHAPE_OPTION_RECT,
      size: 48,
    });
  });

  it('Shows an item link', () => {
    const groupFullName = wrapper.findByText(mockFullName);

    expect(groupFullName.attributes('href')).toBe(mockHref);
  });

  it('Shows description', () => {
    expect(wrapper.text()).toContain(mockDescription);
  });

  it('Shows owner badge', () => {
    createComponent({ props: { isOwner: true } });

    expect(findBadge().text()).toBe(s__('Runner|Owner'));
  });
});