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

title_spec.js « fields « components « issue_show « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 783ce9eb76cc0575911699ff20aec88df05c0b78 (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
import { shallowMount } from '@vue/test-utils';
import TitleField from '~/issue_show/components/fields/title.vue';
import eventHub from '~/issue_show/event_hub';

describe('Title field component', () => {
  let wrapper;

  const findInput = () => wrapper.find({ ref: 'input' });

  beforeEach(() => {
    jest.spyOn(eventHub, '$emit');

    wrapper = shallowMount(TitleField, {
      propsData: {
        formState: {
          title: 'test',
        },
      },
    });
  });

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

  it('renders form control with formState title', () => {
    expect(findInput().element.value).toBe('test');
  });

  it('triggers update with meta+enter', () => {
    findInput().trigger('keydown.enter', { metaKey: true });

    expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
  });

  it('triggers update with ctrl+enter', () => {
    findInput().trigger('keydown.enter', { ctrlKey: true });

    expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
  });
});