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
66
|
import { GlFormCheckbox } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import SignupCheckbox from '~/pages/admin/application_settings/general/components/signup_checkbox.vue';
describe('Signup Form', () => {
let wrapper;
const props = {
name: 'name',
helpText: 'some help text',
label: 'a label',
value: true,
dataQaSelector: 'qa_selector',
};
const mountComponent = () => {
wrapper = shallowMount(SignupCheckbox, {
propsData: props,
stubs: {
GlFormCheckbox,
},
});
};
const findByTestId = (id) => wrapper.find(`[data-testid="${id}"]`);
const findHiddenInput = () => findByTestId('input');
const findCheckbox = () => wrapper.find(GlFormCheckbox);
const findCheckboxLabel = () => findByTestId('label');
const findHelpText = () => findByTestId('helpText');
afterEach(() => {
wrapper.destroy();
});
describe('Signup Checkbox', () => {
beforeEach(() => {
mountComponent();
});
describe('hidden input element', () => {
it('gets passed correct values from props', () => {
expect(findHiddenInput().attributes('name')).toBe(props.name);
expect(findHiddenInput().attributes('value')).toBe('1');
});
});
describe('checkbox', () => {
it('gets passed correct checked value', () => {
expect(findCheckbox().attributes('checked')).toBe('true');
});
it('gets passed correct label', () => {
expect(findCheckboxLabel().text()).toBe(props.label);
});
it('gets passed correct help text', () => {
expect(findHelpText().text()).toBe(props.helpText);
});
it('gets passed data qa selector', () => {
expect(findCheckbox().attributes('data-qa-selector')).toBe(props.dataQaSelector);
});
});
});
});
|