blob: ddce07954abcd3799a9f5394595d263fec9c1e1e (
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
|
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import MissingBranchComponent from '~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue';
let wrapper;
async function factory(sourceBranchRemoved, mergeRequestWidgetGraphql) {
wrapper = shallowMount(MissingBranchComponent, {
propsData: {
mr: { sourceBranchRemoved },
},
provide: {
glFeatures: { mergeRequestWidgetGraphql },
},
});
if (mergeRequestWidgetGraphql) {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({ state: { sourceBranchExists: !sourceBranchRemoved } });
}
await nextTick();
}
describe('MRWidgetMissingBranch', () => {
afterEach(() => {
wrapper.destroy();
});
[true, false].forEach((mergeRequestWidgetGraphql) => {
describe(`widget GraphQL feature flag is ${
mergeRequestWidgetGraphql ? 'enabled' : 'disabled'
}`, () => {
it.each`
sourceBranchRemoved | branchName
${true} | ${'source'}
${false} | ${'target'}
`(
'should set missing branch name as $branchName when sourceBranchRemoved is $sourceBranchRemoved',
async ({ sourceBranchRemoved, branchName }) => {
await factory(sourceBranchRemoved, mergeRequestWidgetGraphql);
expect(wrapper.find('[data-testid="widget-content"]').text()).toContain(branchName);
},
);
});
});
});
|