blob: 42526590ebb78b6e56e18206959e8376c19f2528 (
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 { GlIcon } from '@gitlab/ui';
import ScrollButton from '~/ide/components/jobs/detail/scroll_button.vue';
describe('IDE job log scroll button', () => {
let wrapper;
const createComponent = props => {
wrapper = shallowMount(ScrollButton, {
propsData: {
direction: 'up',
disabled: false,
...props,
},
});
};
afterEach(() => {
wrapper.destroy();
});
describe.each`
direction | icon | title
${'up'} | ${'scroll_up'} | ${'Scroll to top'}
${'down'} | ${'scroll_down'} | ${'Scroll to bottom'}
`('for $direction direction', ({ direction, icon, title }) => {
beforeEach(() => createComponent({ direction }));
it('returns proper icon name', () => {
expect(wrapper.find(GlIcon).props('name')).toBe(icon);
});
it('returns proper title', () => {
expect(wrapper.attributes('data-original-title')).toBe(title);
});
});
it('emits click event on click', () => {
createComponent();
wrapper.find('button').trigger('click');
expect(wrapper.emitted().click).toBeDefined();
});
it('disables button when disabled is true', () => {
createComponent({ disabled: true });
expect(wrapper.find('button').attributes('disabled')).toBe('disabled');
});
});
|