blob: 3592fa50622a9f2880f2e69f0704c0ec82466751 (
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
51
52
53
54
55
56
57
|
import { nextTick } from 'vue';
import { GlLink } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import Protections, {
i18n,
} from '~/projects/settings/branch_rules/components/protections/index.vue';
import PushProtections from '~/projects/settings/branch_rules/components/protections/push_protections.vue';
import MergeProtections from '~/projects/settings/branch_rules/components/protections/merge_protections.vue';
import { protections } from '../../mock_data';
describe('Branch Protections', () => {
let wrapper;
const createComponent = async () => {
wrapper = mountExtended(Protections, {
propsData: { protections },
});
await nextTick();
};
const findHeading = () => wrapper.find('h4');
const findHelpText = () => wrapper.findByTestId('protections-help-text');
const findHelpLink = () => wrapper.findComponent(GlLink);
const findPushProtections = () => wrapper.findComponent(PushProtections);
const findMergeProtections = () => wrapper.findComponent(MergeProtections);
beforeEach(() => createComponent());
afterEach(() => {
wrapper.destroy();
});
it('renders a heading', () => {
expect(findHeading().text()).toBe(i18n.protections);
});
it('renders help text', () => {
expect(findHelpText().text()).toMatchInterpolatedText(i18n.protectionsHelpText);
expect(findHelpLink().attributes('href')).toBe('/help/user/project/protected_branches');
});
it('renders a PushProtections component with correct props', () => {
expect(findPushProtections().props('membersAllowedToPush')).toStrictEqual(
protections.membersAllowedToPush,
);
expect(findPushProtections().props('allowForcePush')).toBe(protections.allowForcePush);
});
it('renders a MergeProtections component with correct props', () => {
expect(findMergeProtections().props('membersAllowedToMerge')).toStrictEqual(
protections.membersAllowedToMerge,
);
expect(findMergeProtections().props('requireCodeOwnersApproval')).toBe(
protections.requireCodeOwnersApproval,
);
});
});
|