Skip to content

Commit

Permalink
feat(eventing): Emit staged change event for cancel status (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze authored Sep 10, 2020
1 parent a4122b6 commit ae9921a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/store/eventing/__tests__/staged-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('store/eventing/staged', () => {
prev | next | expectedStatus
${null} | ${null} | ${null}
${null} | ${'notnull'} | ${'create'}
${'notnull'} | ${null} | ${null}
${'notnull'} | ${null} | ${'cancel'}
${'notnull'} | ${'notnull'} | ${'update'}
`(
'should return $expectedStatus if prevStaged=$prev and nextStaged=$next',
Expand All @@ -74,12 +74,8 @@ describe('store/eventing/staged', () => {
});

describe('handleSetStagedAction()', () => {
test.each`
prev | next
${createStore().getState()} | ${createStore().getState()}
${getCreatorState()} | ${createStore().getState()}
`('should not emit event if status or type is null', ({ prev, next }) => {
handleSetStagedAction(prev, next);
test('should not emit event if status or type is null', () => {
handleSetStagedAction(createStore().getState(), createStore().getState());

expect(eventManager.emit).not.toHaveBeenCalled();
});
Expand Down
4 changes: 2 additions & 2 deletions src/store/eventing/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const getStatus = (prevStaged: CreatorItem, nextStaged: CreatorItem): Sta
status = 'create';
}

if (prevStaged !== null && nextStaged !== null) {
status = 'update';
if (prevStaged !== null) {
status = nextStaged === null ? 'cancel' : 'update';
}

return status;
Expand Down

0 comments on commit ae9921a

Please sign in to comment.