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
|
import { GlFormGroup, GlFormCheckbox } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import MergeProtections, {
i18n,
} from '~/projects/settings/branch_rules/components/protections/merge_protections.vue';
import { membersAllowedToMerge, requireCodeOwnersApproval } from '../../mock_data';
describe('Merge Protections', () => {
let wrapper;
const propsData = {
membersAllowedToMerge,
requireCodeOwnersApproval,
};
const createComponent = () => {
wrapper = mountExtended(MergeProtections, {
propsData,
});
};
const findFormGroup = () => wrapper.findComponent(GlFormGroup);
const findCodeOwnersApprovalCheckbox = () => wrapper.findComponent(GlFormCheckbox);
beforeEach(() => createComponent());
afterEach(() => {
wrapper.destroy();
});
it('renders a form group with the correct label', () => {
expect(findFormGroup().text()).toContain(i18n.allowedToMerge);
});
describe('Require code owners approval checkbox', () => {
it('renders a checkbox with the correct props', () => {
expect(findCodeOwnersApprovalCheckbox().vm.$attrs.checked).toBe(
propsData.requireCodeOwnersApproval,
);
});
it('renders help text', () => {
expect(findCodeOwnersApprovalCheckbox().text()).toContain(i18n.requireApprovalTitle);
expect(findCodeOwnersApprovalCheckbox().text()).toContain(i18n.requireApprovalHelpText);
});
it('emits a change-allow-force-push event when changed', () => {
findCodeOwnersApprovalCheckbox().vm.$emit('change', false);
expect(wrapper.emitted('change-require-code-owners-approval')[0]).toEqual([false]);
});
});
});
|