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
67
68
69
70
71
72
73
|
import { shallowMount } from '@vue/test-utils';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import ciGroupVariables from '~/ci/ci_variable_list/components/ci_group_variables.vue';
import ciVariableShared from '~/ci/ci_variable_list/components/ci_variable_shared.vue';
import { GRAPHQL_GROUP_TYPE } from '~/ci/ci_variable_list/constants';
const mockProvide = {
glFeatures: {
groupScopedCiVariables: false,
},
groupPath: '/group',
groupId: 12,
};
describe('Ci Group Variable wrapper', () => {
let wrapper;
const findCiShared = () => wrapper.findComponent(ciVariableShared);
const createComponent = ({ provide = {} } = {}) => {
wrapper = shallowMount(ciGroupVariables, {
provide: { ...mockProvide, ...provide },
});
};
afterEach(() => {
wrapper.destroy();
});
describe('Props', () => {
beforeEach(() => {
createComponent();
});
it('are passed down the correctly to ci_variable_shared', () => {
expect(findCiShared().props()).toEqual({
id: convertToGraphQLId(GRAPHQL_GROUP_TYPE, mockProvide.groupId),
areScopedVariablesAvailable: false,
componentName: 'GroupVariables',
entity: 'group',
fullPath: mockProvide.groupPath,
hideEnvironmentScope: false,
mutationData: wrapper.vm.$options.mutationData,
queryData: wrapper.vm.$options.queryData,
refetchAfterMutation: false,
});
});
});
describe('feature flag', () => {
describe('When enabled', () => {
beforeEach(() => {
createComponent({ provide: { glFeatures: { groupScopedCiVariables: true } } });
});
it('Passes down `true` to variable shared component', () => {
expect(findCiShared().props('areScopedVariablesAvailable')).toBe(true);
});
});
describe('When disabled', () => {
beforeEach(() => {
createComponent({ provide: { glFeatures: { groupScopedCiVariables: false } } });
});
it('Passes down `false` to variable shared component', () => {
expect(findCiShared().props('areScopedVariablesAvailable')).toBe(false);
});
});
});
});
|