Commit 4fd56ebf authored by Stan Hu's avatar Stan Hu

Revise ee/spec/javascripts/epic/store/actions_spec.js spec

1. Move expectation into the callback we give to `testAction`
2. Uses `jasmine.objectContaining` instead of an off-the-fly custom
matcher.
3. Replaces `stateSubscribed` with simply mutating the shared `state`
object we're creating for each test (it was a little weird to see
`stateSubscribed.subscribes`)
parent 2a0ca652
...@@ -776,14 +776,15 @@ describe('Epic Store Actions', () => { ...@@ -776,14 +776,15 @@ describe('Epic Store Actions', () => {
__typename: 'EpicSetSubscriptionPayload', __typename: 'EpicSetSubscriptionPayload',
}, },
}; };
const stateSubscribed = {
epicIid: 123,
groupPath: 'charts',
fullPath: 'gitlab-org/charts',
subscribed: false,
};
beforeEach(() => { beforeEach(() => {
Object.assign(state, {
epicIid: 123,
groupPath: 'charts',
fullPath: 'gitlab-org/charts',
subscribed: false,
});
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
}); });
...@@ -802,8 +803,8 @@ describe('Epic Store Actions', () => { ...@@ -802,8 +803,8 @@ describe('Epic Store Actions', () => {
testAction( testAction(
actions.toggleEpicSubscription, actions.toggleEpicSubscription,
{ subscribed: !stateSubscribed.subscribed }, { subscribed: !state.subscribed },
stateSubscribed, state,
[], [],
[ [
{ {
...@@ -811,24 +812,25 @@ describe('Epic Store Actions', () => { ...@@ -811,24 +812,25 @@ describe('Epic Store Actions', () => {
}, },
{ {
type: 'requestEpicSubscriptionToggleSuccess', type: 'requestEpicSubscriptionToggleSuccess',
payload: { subscribed: !stateSubscribed.subscribed }, payload: { subscribed: !state.subscribed },
}, },
], ],
done, () => {
); expect(epicUtils.gqClient.mutate).toHaveBeenCalledWith(
jasmine.objectContaining({
const tester = { variables: jasmine.objectContaining({
asymmetricMatch(actual) { epicSetSubscriptionInput: {
const variables = actual.variables.epicSetSubscriptionInput; iid: `${state.epicIid}`,
groupPath: state.fullPath,
return ( subscribedState: !state.subscribed,
variables.iid === `${stateSubscribed.epicIid}` && },
variables.groupPath === stateSubscribed.fullPath }),
}),
); );
},
};
expect(epicUtils.gqClient.mutate).toHaveBeenCalledWith(tester); done();
},
);
}); });
}); });
...@@ -848,8 +850,8 @@ describe('Epic Store Actions', () => { ...@@ -848,8 +850,8 @@ describe('Epic Store Actions', () => {
testAction( testAction(
actions.toggleEpicSubscription, actions.toggleEpicSubscription,
{ subscribed: !stateSubscribed.subscribed }, { subscribed: !state.subscribed },
stateSubscribed, state,
[], [],
[ [
{ {
......
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