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

terminal_controls_spec.js « terminal « components « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 99182710218722242cb11516dace5976a898272a (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
55
56
57
58
59
60
61
62
63
64
65
import { shallowMount } from '@vue/test-utils';
import TerminalControls from '~/ide/components/terminal/terminal_controls.vue';
import ScrollButton from '~/ide/components/jobs/detail/scroll_button.vue';

describe('IDE TerminalControls', () => {
  let wrapper;
  let buttons;

  const factory = (options = {}) => {
    wrapper = shallowMount(TerminalControls, {
      ...options,
    });

    buttons = wrapper.findAll(ScrollButton);
  };

  it('shows an up and down scroll button', () => {
    factory();

    expect(buttons.wrappers.map((x) => x.props())).toEqual([
      expect.objectContaining({ direction: 'up', disabled: true }),
      expect.objectContaining({ direction: 'down', disabled: true }),
    ]);
  });

  it('enables up button with prop', () => {
    factory({ propsData: { canScrollUp: true } });

    expect(buttons.at(0).props()).toEqual(
      expect.objectContaining({ direction: 'up', disabled: false }),
    );
  });

  it('enables down button with prop', () => {
    factory({ propsData: { canScrollDown: true } });

    expect(buttons.at(1).props()).toEqual(
      expect.objectContaining({ direction: 'down', disabled: false }),
    );
  });

  it('emits "scroll-up" when click up button', () => {
    factory({ propsData: { canScrollUp: true } });

    expect(wrapper.emitted()).toEqual({});

    buttons.at(0).vm.$emit('click');

    return wrapper.vm.$nextTick().then(() => {
      expect(wrapper.emitted('scroll-up')).toEqual([[]]);
    });
  });

  it('emits "scroll-down" when click down button', () => {
    factory({ propsData: { canScrollDown: true } });

    expect(wrapper.emitted()).toEqual({});

    buttons.at(1).vm.$emit('click');

    return wrapper.vm.$nextTick().then(() => {
      expect(wrapper.emitted('scroll-down')).toEqual([[]]);
    });
  });
});