Commit a80f2579 authored by Denys Mishunov's avatar Denys Mishunov

Passed the parameter to mount or shallowMount

Instead of creating a new factory that produces the code
duplication, we can rely on a passed parameter instead.
parent 5180959f
...@@ -57,25 +57,9 @@ describe('ReadyToMerge', () => { ...@@ -57,25 +57,9 @@ describe('ReadyToMerge', () => {
mergeTrainsCount: 0, mergeTrainsCount: 0,
}; };
const factory = (mrUpdates = {}) => { const factory = (mrUpdates = {}, shallow = true) => {
wrapper = shallowMount(ReadyToMerge, { const func = shallow ? shallowMount : mount;
propsData: { wrapper = func(ReadyToMerge, {
mr: { ...mr, ...mrUpdates },
service,
},
stubs: {
MergeImmediatelyConfirmationDialog,
MergeTrainHelperText,
GlSprintf,
GlLink,
},
});
({ vm } = wrapper);
};
const mountedFactory = (mrUpdates = {}) => {
wrapper = mount(ReadyToMerge, {
propsData: { propsData: {
mr: { ...mr, ...mrUpdates }, mr: { ...mr, ...mrUpdates },
service, service,
...@@ -354,7 +338,7 @@ describe('ReadyToMerge', () => { ...@@ -354,7 +338,7 @@ describe('ReadyToMerge', () => {
}; };
it('should show a warning dialog asking for confirmation if the user is trying to skip the merge train', () => { it('should show a warning dialog asking for confirmation if the user is trying to skip the merge train', () => {
mountedFactory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }); factory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }, false);
return clickMergeImmediately().then(() => { return clickMergeImmediately().then(() => {
expect(dialog.vm.show).toHaveBeenCalled(); expect(dialog.vm.show).toHaveBeenCalled();
expect(vm.handleMergeButtonClick).not.toHaveBeenCalled(); expect(vm.handleMergeButtonClick).not.toHaveBeenCalled();
...@@ -362,7 +346,7 @@ describe('ReadyToMerge', () => { ...@@ -362,7 +346,7 @@ describe('ReadyToMerge', () => {
}); });
it('should perform the merge when the user confirms their intent to merge immediately', () => { it('should perform the merge when the user confirms their intent to merge immediately', () => {
mountedFactory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }); factory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }, false);
return clickMergeImmediately() return clickMergeImmediately()
.then(() => { .then(() => {
dialog.vm.$emit('mergeImmediately'); dialog.vm.$emit('mergeImmediately');
...@@ -374,10 +358,13 @@ describe('ReadyToMerge', () => { ...@@ -374,10 +358,13 @@ describe('ReadyToMerge', () => {
}); });
it('should not ask for confirmation in non-merge train scenarios', () => { it('should not ask for confirmation in non-merge train scenarios', () => {
mountedFactory({ factory(
isPipelineActive: true, {
onlyAllowMergeIfPipelineSucceeds: false, isPipelineActive: true,
}); onlyAllowMergeIfPipelineSucceeds: false,
},
false,
);
return clickMergeImmediately().then(() => { return clickMergeImmediately().then(() => {
expect(dialog.vm.show).not.toHaveBeenCalled(); expect(dialog.vm.show).not.toHaveBeenCalled();
expect(vm.handleMergeButtonClick).toHaveBeenCalled(); expect(vm.handleMergeButtonClick).toHaveBeenCalled();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment