Skip to content

Commit

Permalink
refactor: fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Mar 29, 2024
1 parent f608fff commit ca121b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Expand Up @@ -9,11 +9,11 @@ import { UserApiTest } from '#src/helpers/user.js';
const getUsers = async <T>(
init: string[][] | Record<string, string> | URLSearchParams
): Promise<{ headers: Headers; json: T }> => {
const { headers, json } = await authedAdminApi.get('users', {
const response = await authedAdminApi.get('users', {
searchParams: new URLSearchParams(init),
});

return { headers, json: (await json()) as T };
return { headers: response.headers, json: (await response.json()) as T };
};

describe('admin console user search params', () => {
Expand Down
Expand Up @@ -13,9 +13,8 @@ const randomId = () => generateStandardId(4);

const expectErrorResponse = async (error: unknown, statusCode: number, code: string) => {
assert(error instanceof HTTPError);
const { status, json } = error.response;
expect(status).toBe(statusCode);
expect(await json()).toMatchObject({ code });
expect(error.response.status).toBe(statusCode);
expect(await error.response.json()).toMatchObject({ code });
};

describe('organization invitation creation', () => {
Expand Down
Expand Up @@ -11,10 +11,8 @@ const randomId = () => generateStandardId(4);

const expectErrorResponse = async (error: unknown, statusCode: number, code: string) => {
assert(error instanceof HTTPError);
const { status, json } = error.response;

expect(status).toBe(statusCode);
expect(await json()).toMatchObject({ code });
expect(error.response.status).toBe(statusCode);
expect(await error.response.json()).toMatchObject({ code });
};

describe('organization invitation status update', () => {
Expand Down

0 comments on commit ca121b0

Please sign in to comment.