Commit f6325145 authored by jboyson's avatar jboyson

Update tests to account for broken scenario

parent 3a3f6778
......@@ -28,11 +28,11 @@ function convertPropsToGraphqlState(props) {
};
}
function factory(propsData) {
function factory(propsData, stateOverride = {}) {
let state = {};
if (mergeRequestWidgetGraphqlEnabled) {
state = convertPropsToGraphqlState(propsData);
state = { ...convertPropsToGraphqlState(propsData), ...stateOverride };
}
wrapper = extendedWrapper(
......@@ -125,7 +125,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
},
);
it('should return false when shouldRemoveSourceBranch set to false', () => {
it('should not find "Delete" button when shouldRemoveSourceBranch set to true', () => {
factory({
...defaultMrProps(),
shouldRemoveSourceBranch: true,
......@@ -134,6 +134,29 @@ describe('MRWidgetAutoMergeEnabled', () => {
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(false);
});
it('should find "Delete" button when shouldRemoveSourceBranch overrides state.forceRemoveSourceBranch', () => {
factory(
{
...defaultMrProps(),
shouldRemoveSourceBranch: false,
},
{
forceRemoveSourceBranch: true,
},
);
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(true);
});
it('should find "Delete" button when shouldRemoveSourceBranch set to false', () => {
factory({
...defaultMrProps(),
shouldRemoveSourceBranch: false,
});
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(true);
});
it('should return false if user is not able to remove the source branch', () => {
factory({
...defaultMrProps(),
......
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