Skip to content

Commit 56f4559

Browse files
committed
Keep redirect assertions in awaited tests
1 parent 71196f2 commit 56f4559

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎packages/node/test/unit/contract-auth.test.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,17 @@ it('preserves OAuth errors as data without retries or unsafe messages', async ()
167167
})
168168

169169
it('retains redirect rejection for credentialless calls', async () => {
170-
const requests: string[] = []
170+
const requests: {
171+
url: string | undefined
172+
authorization: string | undefined
173+
cookie: string | undefined
174+
}[] = []
171175
const server = createServer((request, response) => {
172-
requests.push(request.url ?? '')
173-
expect(request.headers.authorization).toBeUndefined()
174-
expect(request.headers.cookie).toBeUndefined()
176+
requests.push({
177+
url: request.url,
178+
authorization: request.headers.authorization,
179+
cookie: request.headers.cookie,
180+
})
175181
response.writeHead(307, { location: '/must-not-follow' })
176182
response.end()
177183
})
@@ -186,8 +192,8 @@ it('retains redirect rejection for credentialless calls', async () => {
186192
})
187193
await expect(
188194
client.issueBearerToken({ body: { grant_type: 'refresh_token' } }),
189-
).rejects.toThrow()
190-
expect(requests).toEqual(['/token'])
195+
).rejects.toBeInstanceOf(TypeError)
196+
expect(requests).toEqual([{ url: '/token', authorization: undefined, cookie: undefined }])
191197
} finally {
192198
server.closeAllConnections()
193199
await new Promise<void>((resolve, reject) =>

0 commit comments

Comments
 (0)