Skip to content

Commit

Permalink
fix: ok statusCode can be 200..299 (#7919)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed May 14, 2022
1 parent b1a3aa9 commit d1504f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/rest/__tests__/REST.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ test('postEcho', async () => {
expect(await api.post('/postEcho', { body: { foo: 'bar' } })).toStrictEqual({ foo: 'bar' });
});

test('201 status code', async () => {
mockPool
.intercept({
path: genPath('/postNon200StatusCode'),
method: 'POST',
})
.reply((t) => ({
data: t.body!,
statusCode: 201,
responseOptions,
}));

expect(await api.post('/postNon200StatusCode', { body: { foo: 'bar' } })).toStrictEqual({ foo: 'bar' });
});

test('Old Message Delete Edge-Case: Old message', async () => {
mockPool
.intercept({
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/src/lib/handlers/SequentialHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export class SequentialHandler implements IHandler {
}
}

if (status === 200) {
if (status >= 200 && status < 300) {
return parseResponse(res);
} else if (status === 429) {
// A rate limit was hit - this may happen if the route isn't associated with an official bucket hash yet, or when first globally rate limited
Expand Down

0 comments on commit d1504f2

Please sign in to comment.