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

blob_edit_header_spec.js « components « blob « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db7d7d7d48d9e3c82bf457702424319e35622db2 (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
import { shallowMount } from '@vue/test-utils';
import BlobEditHeader from '~/blob/components/blob_edit_header.vue';
import { GlFormInput } from '@gitlab/ui';

describe('Blob Header Editing', () => {
  let wrapper;
  const value = 'foo.md';

  function createComponent() {
    wrapper = shallowMount(BlobEditHeader, {
      propsData: {
        value,
      },
    });
  }

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

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

  describe('rendering', () => {
    it('matches the snapshot', () => {
      expect(wrapper.element).toMatchSnapshot();
    });

    it('contains a form input field', () => {
      expect(wrapper.contains(GlFormInput)).toBe(true);
    });
  });

  describe('functionality', () => {
    it('emits input event when the blob name is changed', () => {
      const inputComponent = wrapper.find(GlFormInput);
      const newValue = 'bar.txt';

      wrapper.setData({
        name: newValue,
      });
      inputComponent.vm.$emit('change');

      return wrapper.vm.$nextTick().then(() => {
        expect(wrapper.emitted().input[0]).toEqual([newValue]);
      });
    });
  });
});