debian-mirror-gitlab/spec/frontend/ide/components/terminal/terminal_controls_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import { shallowMount } from '@vue/test-utils';
2022-04-04 11:22:00 +05:30
import { nextTick } from 'vue';
2020-06-23 00:09:42 +05:30
import ScrollButton from '~/ide/components/jobs/detail/scroll_button.vue';
2021-03-11 19:13:27 +05:30
import TerminalControls from '~/ide/components/terminal/terminal_controls.vue';
2020-06-23 00:09:42 +05:30
describe('IDE TerminalControls', () => {
let wrapper;
let buttons;
const factory = (options = {}) => {
wrapper = shallowMount(TerminalControls, {
...options,
});
2022-08-27 11:52:29 +05:30
buttons = wrapper.findAllComponents(ScrollButton);
2020-06-23 00:09:42 +05:30
};
it('shows an up and down scroll button', () => {
factory();
2021-03-08 18:12:59 +05:30
expect(buttons.wrappers.map((x) => x.props())).toEqual([
2020-06-23 00:09:42 +05:30
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 }),
);
});
2022-04-04 11:22:00 +05:30
it('emits "scroll-up" when click up button', async () => {
2020-06-23 00:09:42 +05:30
factory({ propsData: { canScrollUp: true } });
2020-11-24 15:15:51 +05:30
expect(wrapper.emitted()).toEqual({});
2020-06-23 00:09:42 +05:30
buttons.at(0).vm.$emit('click');
2022-04-04 11:22:00 +05:30
await nextTick();
expect(wrapper.emitted('scroll-up')).toEqual([[]]);
2020-06-23 00:09:42 +05:30
});
2022-04-04 11:22:00 +05:30
it('emits "scroll-down" when click down button', async () => {
2020-06-23 00:09:42 +05:30
factory({ propsData: { canScrollDown: true } });
2020-11-24 15:15:51 +05:30
expect(wrapper.emitted()).toEqual({});
2020-06-23 00:09:42 +05:30
buttons.at(1).vm.$emit('click');
2022-04-04 11:22:00 +05:30
await nextTick();
expect(wrapper.emitted('scroll-down')).toEqual([[]]);
2020-06-23 00:09:42 +05:30
});
});