Skip to content

Commit 6883b2d

Browse files
committed
chore: use rejects assertion in "reject" tests
1 parent beaa4c7 commit 6883b2d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/reject.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@ import { createDeferredExecutor } from '../src/createDeferredExecutor'
22

33
it('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

1616
it('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
})

0 commit comments

Comments
 (0)