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

organization_avatar_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: c98fa14e49bc573aa64f02a3a793763b1141dd45 (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
import { GlAvatar, GlIcon } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import OrganizationAvatar from '~/organizations/show/components/organization_avatar.vue';
import {
  VISIBILITY_TYPE_ICON,
  ORGANIZATION_VISIBILITY_TYPE,
  VISIBILITY_LEVEL_PUBLIC_STRING,
} from '~/visibility_level/constants';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';

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

  const defaultPropsData = {
    organization: {
      id: 1,
      name: 'GitLab',
    },
  };

  const createComponent = () => {
    wrapper = shallowMountExtended(OrganizationAvatar, {
      propsData: defaultPropsData,
      directives: {
        GlTooltip: createMockDirective('gl-tooltip'),
      },
    });
  };

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

  it('renders avatar', () => {
    expect(wrapper.findComponent(GlAvatar).props()).toMatchObject({
      entityId: defaultPropsData.organization.id,
      entityName: defaultPropsData.organization.name,
    });
  });

  it('renders organization name', () => {
    expect(
      wrapper.findByRole('heading', { name: defaultPropsData.organization.name }).exists(),
    ).toBe(true);
  });

  it('renders visibility icon', () => {
    const icon = wrapper.findComponent(GlIcon);
    const tooltip = getBinding(icon.element, 'gl-tooltip');

    expect(icon.props('name')).toBe(VISIBILITY_TYPE_ICON[VISIBILITY_LEVEL_PUBLIC_STRING]);
    expect(tooltip.value).toBe(ORGANIZATION_VISIBILITY_TYPE[VISIBILITY_LEVEL_PUBLIC_STRING]);
  });

  it('renders button to copy organization ID', () => {
    expect(wrapper.findComponent(ClipboardButton).props()).toMatchObject({
      category: 'tertiary',
      title: 'Copy organization ID',
      text: '1',
      size: 'small',
    });
  });
});