Skip to content

Commit

Permalink
tests: Fix tests after #190
Browse files Browse the repository at this point in the history
- Pull in the relevant types package for `@sinonjs/fake-timers`
- Convert those tests from tap to Jest
- Add some Typescript types to those tests
  • Loading branch information
wolfy1339 committed Aug 25, 2020
1 parent a8ae002 commit 74a6c52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/node": "^14.0.14",
"@types/prettier": "^2.0.0",
"@types/simple-mock": "^0.8.1",
"@types/sinonjs__fake-timers": "^6.0.1",
"axios": "^0.20.0",
"cheerio": "^1.0.0-rc.2",
"get-port": "^5.0.0",
Expand Down
14 changes: 9 additions & 5 deletions test/integration/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ test("POST / with hook error", (t) => {
});

test("POST / with timeout", async (t) => {
t.plan(1);
expect.assertions(1);

const clock = FakeTimers.install({
toFake: ["setTimeout"],
Expand Down Expand Up @@ -277,18 +277,22 @@ test("POST / with timeout", async (t) => {
});
})

.catch(t.error)
.catch((error: AxiosError) => {
expect(error.response.status).toBe(400);
})

.then((result) => {
t.is(result.status, 202);
.then((result: AxiosResponse) => {
expect(result.status).toBe(202);
})

.then(() => {
server.close();
clock.uninstall();
})

.catch(t.error);
.catch((error: AxiosError) => {
expect(error.response.status).toBe(400);
});

await clock.nextAsync();
await clock.nextAsync();
Expand Down

0 comments on commit 74a6c52

Please sign in to comment.