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', () => {
mergeTrainsCount: 0,
};
const factory = (mrUpdates = {}) => {
wrapper = shallowMount(ReadyToMerge, {
propsData: {
mr: { ...mr, ...mrUpdates },
service,
},
stubs: {
MergeImmediatelyConfirmationDialog,
MergeTrainHelperText,
GlSprintf,
GlLink,
},
});
({ vm } = wrapper);
};
const mountedFactory = (mrUpdates = {}) => {
wrapper = mount(ReadyToMerge, {
const factory = (mrUpdates = {}, shallow = true) => {
const func = shallow ? shallowMount : mount;
wrapper = func(ReadyToMerge, {
propsData: {
mr: { ...mr, ...mrUpdates },
service,
......@@ -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', () => {
mountedFactory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY });
factory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }, false);
return clickMergeImmediately().then(() => {
expect(dialog.vm.show).toHaveBeenCalled();
expect(vm.handleMergeButtonClick).not.toHaveBeenCalled();
......@@ -362,7 +346,7 @@ describe('ReadyToMerge', () => {
});
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()
.then(() => {
dialog.vm.$emit('mergeImmediately');
......@@ -374,10 +358,13 @@ describe('ReadyToMerge', () => {
});
it('should not ask for confirmation in non-merge train scenarios', () => {
mountedFactory({
isPipelineActive: true,
onlyAllowMergeIfPipelineSucceeds: false,
});
factory(
{
isPipelineActive: true,
onlyAllowMergeIfPipelineSucceeds: false,
},
false,
);
return clickMergeImmediately().then(() => {
expect(dialog.vm.show).not.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