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 { GlFormGroup, GlSprintf, GlFormCheckbox } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PushProtections, {
i18n,
} from '~/projects/settings/branch_rules/components/edit/protections/push_protections.vue';
import { membersAllowedToPush, allowForcePush } from '../../../mock_data';
describe('Push Protections', () => {
let wrapper;
const propsData = {
membersAllowedToPush,
allowForcePush,
};
const createComponent = () => {
wrapper = shallowMountExtended(PushProtections, {
propsData,
});
};
const findFormGroup = () => wrapper.findComponent(GlFormGroup);
const findAllowForcePushCheckbox = () => wrapper.findComponent(GlFormCheckbox);
const findHelpText = () => wrapper.findComponent(GlSprintf);
beforeEach(() => createComponent());
afterEach(() => {
wrapper.destroy();
});
it('renders a form group with the correct label', () => {
expect(findFormGroup().attributes('label')).toBe(i18n.allowedToPush);
});
describe('Allow force push checkbox', () => {
it('renders a checkbox with the correct props', () => {
expect(findAllowForcePushCheckbox().vm.$attrs.checked).toBe(propsData.allowForcePush);
});
it('renders help text', () => {
expect(findHelpText().attributes('message')).toBe(i18n.forcePushTitle);
});
it('emits a change-allow-force-push event when changed', () => {
findAllowForcePushCheckbox().vm.$emit('change', false);
expect(wrapper.emitted('change-allow-force-push')[0]).toEqual([false]);
});
});
});
|