Skip to content

Commit

Permalink
Add test for non-existent route returning 404 and refactor root route…
Browse files Browse the repository at this point in the history
… test
  • Loading branch information
tryb3l committed Sep 18, 2024
1 parent 252975b commit 92fe20b
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions test/routes/root.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
"use strict";
'use strict'

const { test } = require("tap");
const { buildApp } = require("../helper");
const { test } = require('tap')
const { buildApp } = require('../helper')

test("default root route", async (t) => {
const app = await buildApp(t);
test('default root route', async (t) => {
const app = await buildApp(t)

const res = await app.inject({
url: "/",
});
t.same(JSON.parse(res.payload), { root: true });
});
url: '/',
})
t.same(JSON.parse(res.payload), { root: true })
})

test('non-existent route returns 404', async (t) => {
const app = await buildApp(t)

const res = await app.inject({
url: '/non-existent',
})
t.equal(res.statusCode, 404)
t.same(JSON.parse(res.payload), {
statusCode: 404,
error: 'Not Found',
message: 'The requested resource could not be found',
requestId: JSON.parse(res.payload).requestId,
})
})

0 comments on commit 92fe20b

Please sign in to comment.