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

upload_button_spec.js « details « projects « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d730896308891454371e909c8b43cc7663a97464 (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 { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import UploadButton from '~/projects/details/upload_button.vue';
import UploadBlobModal from '~/repository/components/upload_blob_modal.vue';

const MODAL_ID = 'details-modal-upload-blob';

describe('UploadButton', () => {
  let wrapper;
  let glModalDirective;

  const createComponent = () => {
    glModalDirective = jest.fn();

    return shallowMount(UploadButton, {
      directives: {
        glModal: {
          bind(_, { value }) {
            glModalDirective(value);
          },
        },
      },
    });
  };

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

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

  it('displays an upload button', () => {
    expect(wrapper.find(GlButton).exists()).toBe(true);
  });

  it('contains a modal', () => {
    const modal = wrapper.find(UploadBlobModal);

    expect(modal.exists()).toBe(true);
    expect(modal.props('modalId')).toBe(MODAL_ID);
  });

  describe('when clickinig the upload file button', () => {
    beforeEach(() => {
      wrapper.find(GlButton).vm.$emit('click');
    });

    it('opens the modal', () => {
      expect(glModalDirective).toHaveBeenCalledWith(MODAL_ID);
    });
  });
});