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

projects_dropdown_spec.js « components « gitlab_slack_application « integrations « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8879a86a578b1addf5623f842510c41b1ae34d59 (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
import { GlCollapsibleListbox } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import ProjectsDropdown from '~/integrations/gitlab_slack_application/components/projects_dropdown.vue';

describe('Slack application projects dropdown', () => {
  let wrapper;

  const projectsMockData = [
    {
      avatar_url: null,
      id: 1,
      name: 'Gitlab Smoke Tests',
      name_with_namespace: 'Toolbox / Gitlab Smoke Tests',
    },
    {
      avatar_url: null,
      id: 2,
      name: 'Gitlab Test',
      name_with_namespace: 'Gitlab Org / Gitlab Test',
    },
    {
      avatar_url: 'foo/bar',
      id: 3,
      name: 'Gitlab Shell',
      name_with_namespace: 'Gitlab Org / Gitlab Shell',
    },
  ];

  const createComponent = (props = {}) => {
    wrapper = shallowMount(ProjectsDropdown, {
      propsData: {
        projects: projectsMockData,
        ...props,
      },
    });
  };

  const findListbox = () => wrapper.findComponent(GlCollapsibleListbox);

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

  it('renders the listbox with 3 items', () => {
    expect(findListbox().exists()).toBe(true);
    expect(findListbox().props('items')).toHaveLength(3);
  });

  it('should emit project-selected if a project is clicked', () => {
    findListbox().vm.$emit('select', 1);

    expect(wrapper.emitted('project-selected')).toMatchObject([[projectsMockData[0]]]);
  });
});