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

add_namespace_button_spec.js « components « subscriptions « jira_connect « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ec1b7b7932922f0a4d8412270658cc7a5bab532 (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
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import AddNamespaceButton from '~/jira_connect/subscriptions/components/add_namespace_button.vue';
import AddNamespaceModal from '~/jira_connect/subscriptions/components/add_namespace_modal/add_namespace_modal.vue';
import { ADD_NAMESPACE_MODAL_ID } from '~/jira_connect/subscriptions/constants';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';

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

  const createComponent = () => {
    wrapper = shallowMount(AddNamespaceButton, {
      directives: {
        glModal: createMockDirective(),
      },
    });
  };

  const findButton = () => wrapper.findComponent(GlButton);
  const findModal = () => wrapper.findComponent(AddNamespaceModal);

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

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

  it('displays a button', () => {
    expect(findButton().exists()).toBe(true);
  });

  it('contains a modal', () => {
    expect(findModal().exists()).toBe(true);
  });

  it('button is bound to the modal', () => {
    const { value } = getBinding(findButton().element, 'gl-modal');

    expect(value).toBeTruthy();
    expect(value).toBe(ADD_NAMESPACE_MODAL_ID);
  });
});