Skip to content

Commit ae9921a

Browse files
author
Mingze
authored
feat(eventing): Emit staged change event for cancel status (#586)
1 parent a4122b6 commit ae9921a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/store/eventing/__tests__/staged-test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('store/eventing/staged', () => {
5252
prev | next | expectedStatus
5353
${null} | ${null} | ${null}
5454
${null} | ${'notnull'} | ${'create'}
55-
${'notnull'} | ${null} | ${null}
55+
${'notnull'} | ${null} | ${'cancel'}
5656
${'notnull'} | ${'notnull'} | ${'update'}
5757
`(
5858
'should return $expectedStatus if prevStaged=$prev and nextStaged=$next',
@@ -74,12 +74,8 @@ describe('store/eventing/staged', () => {
7474
});
7575

7676
describe('handleSetStagedAction()', () => {
77-
test.each`
78-
prev | next
79-
${createStore().getState()} | ${createStore().getState()}
80-
${getCreatorState()} | ${createStore().getState()}
81-
`('should not emit event if status or type is null', ({ prev, next }) => {
82-
handleSetStagedAction(prev, next);
77+
test('should not emit event if status or type is null', () => {
78+
handleSetStagedAction(createStore().getState(), createStore().getState());
8379

8480
expect(eventManager.emit).not.toHaveBeenCalled();
8581
});

src/store/eventing/staged.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const getStatus = (prevStaged: CreatorItem, nextStaged: CreatorItem): Sta
1414
status = 'create';
1515
}
1616

17-
if (prevStaged !== null && nextStaged !== null) {
18-
status = 'update';
17+
if (prevStaged !== null) {
18+
status = nextStaged === null ? 'cancel' : 'update';
1919
}
2020

2121
return status;

0 commit comments

Comments
 (0)