Skip to content

Commit 92fe20b

Browse files
committed
Add test for non-existent route returning 404 and refactor root route test
1 parent 252975b commit 92fe20b

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

test/routes/root.test.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
"use strict";
1+
'use strict'
22

3-
const { test } = require("tap");
4-
const { buildApp } = require("../helper");
3+
const { test } = require('tap')
4+
const { buildApp } = require('../helper')
55

6-
test("default root route", async (t) => {
7-
const app = await buildApp(t);
6+
test('default root route', async (t) => {
7+
const app = await buildApp(t)
88

99
const res = await app.inject({
10-
url: "/",
11-
});
12-
t.same(JSON.parse(res.payload), { root: true });
13-
});
10+
url: '/',
11+
})
12+
t.same(JSON.parse(res.payload), { root: true })
13+
})
14+
15+
test('non-existent route returns 404', async (t) => {
16+
const app = await buildApp(t)
17+
18+
const res = await app.inject({
19+
url: '/non-existent',
20+
})
21+
t.equal(res.statusCode, 404)
22+
t.same(JSON.parse(res.payload), {
23+
statusCode: 404,
24+
error: 'Not Found',
25+
message: 'The requested resource could not be found',
26+
requestId: JSON.parse(res.payload).requestId,
27+
})
28+
})

0 commit comments

Comments
 (0)