Skip to content

Commit

Permalink
test(refactor): use 'toEqual' instead of 'toStrictEqual' with JSON.st…
Browse files Browse the repository at this point in the history
…ringify in Response assertions (#589)

More context in #588
  • Loading branch information
oscard0m authored Jul 19, 2023
1 parent 94d8c75 commit 00919b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
8 changes: 4 additions & 4 deletions test/graphql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("octokit.graphql()", () => {

const result = await octokit.graphql(query, { login: "octokit" });

expect(JSON.stringify(result)).toStrictEqual(JSON.stringify(mockResult));
expect(result).toEqual(mockResult);
});

it("GitHub Enterprise Server usage (with option.baseUrl)", async () => {
Expand Down Expand Up @@ -84,7 +84,7 @@ describe("octokit.graphql()", () => {

const result = await octokit.graphql(query, { login: "octokit" });

expect(JSON.stringify(result)).toStrictEqual(JSON.stringify(mockResult));
expect(result).toEqual(mockResult);
});

it("custom headers: octokit.graphql({ query, headers })", async () => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe("octokit.graphql()", () => {
},
});

expect(JSON.stringify(result)).toStrictEqual(JSON.stringify({ ok: true }));
expect(result).toEqual({ ok: true });
});

it("custom headers: octokit.graphql(query, { headers })", async () => {
Expand Down Expand Up @@ -145,6 +145,6 @@ describe("octokit.graphql()", () => {
foo: "bar",
});

expect(JSON.stringify(result)).toStrictEqual(JSON.stringify({ ok: true }));
expect(result).toEqual({ ok: true });
});
});
22 changes: 6 additions & 16 deletions test/hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ describe("octokit.hook", () => {

const { data } = await octokit.request("/");

expect(JSON.stringify(data)).toStrictEqual(
JSON.stringify({
ok: true,
afterAddition: "works",
}),
);
expect(data).toEqual({
ok: true,
afterAddition: "works",
});
});

it("octokit.hook.error('request')", async () => {
Expand Down Expand Up @@ -161,11 +159,7 @@ describe("octokit.hook", () => {

const { data } = await octokit.request("/");

expect(JSON.stringify(data)).toStrictEqual(
JSON.stringify({
ok: true,
}),
);
expect(data).toEqual({ ok: true });
});

it("octokit.hook.wrap('request')", async () => {
Expand Down Expand Up @@ -196,11 +190,7 @@ describe("octokit.hook", () => {

const { data } = await octokit.request("/");

expect(JSON.stringify(data)).toStrictEqual(
JSON.stringify({
ok: true,
}),
);
expect(data).toEqual({ ok: true });
});

it("octokit.hook()", async () => {
Expand Down
4 changes: 1 addition & 3 deletions test/issues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ describe("issues", () => {
const response = await octokit.request("/");

expect(response.status).toEqual(200);
expect(JSON.stringify(response.data)).toStrictEqual(
JSON.stringify({ ok: true }),
);
expect(response.data).toEqual({ ok: true });
});
});

0 comments on commit 00919b6

Please sign in to comment.