File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -2,27 +2,26 @@ import { createDeferredExecutor } from '../src/createDeferredExecutor'
22
33it ( 'can be rejected without any reason' , async ( ) => {
44 const executor = createDeferredExecutor < void > ( )
5- const promise = new Promise < void > ( executor ) . catch ( ( ) => { } )
5+ const promise = new Promise < void > ( executor )
66 expect ( executor . state ) . toBe ( 'pending' )
77
88 executor . reject ( )
99 expect ( executor . state ) . toBe ( 'pending' )
1010
11- expect ( await promise ) . toBeUndefined ( )
11+ await expect ( promise ) . rejects . toBeUndefined ( )
1212 expect ( executor . state ) . toBe ( 'rejected' )
1313 expect ( executor . rejectionReason ) . toBeUndefined ( )
1414} )
1515
1616it ( 'can be rejected with a reason' , async ( ) => {
1717 const executor = createDeferredExecutor < void > ( )
18- const promise = new Promise < void > ( executor ) . catch ( ( ) => { } )
18+ const promise = new Promise < void > ( executor )
1919 expect ( executor . state ) . toBe ( 'pending' )
2020
2121 const rejectionReason = new Error ( 'Something went wrong' )
2222 executor . reject ( rejectionReason )
2323 expect ( executor . state ) . toBe ( 'pending' )
2424
25- expect ( await promise ) . toBeUndefined ( )
25+ await expect ( promise ) . rejects . toThrowError ( rejectionReason )
2626 expect ( executor . state ) . toBe ( 'rejected' )
27- expect ( executor . rejectionReason ) . toEqual ( rejectionReason )
2827} )
You can’t perform that action at this time.
0 commit comments