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
|
import { GlIcon } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { __ } from '~/locale';
import Counter from '~/super_sidebar/components/counter.vue';
describe('Counter component', () => {
let wrapper;
const defaultPropsData = {
count: 3,
href: '',
icon: 'issues',
label: __('Issues'),
};
afterEach(() => {
wrapper.destroy();
});
const findButton = () => wrapper.find('button');
const findIcon = () => wrapper.getComponent(GlIcon);
const findLink = () => wrapper.find('a');
const createWrapper = (props = {}) => {
wrapper = shallowMountExtended(Counter, {
propsData: {
...defaultPropsData,
...props,
},
});
};
beforeEach(() => {
createWrapper();
});
describe('default', () => {
it('renders icon', () => {
expect(findIcon().props('name')).toBe('issues');
});
it('renders button', () => {
expect(findButton().attributes('aria-label')).toBe('Issues 3');
expect(findLink().exists()).toBe(false);
});
});
describe('link', () => {
it('renders link', () => {
createWrapper({ href: '/dashboard/todos' });
expect(findLink().attributes('aria-label')).toBe('Issues 3');
expect(findLink().attributes('href')).toBe('/dashboard/todos');
expect(findButton().exists()).toBe(false);
});
});
});
|