From 0c522fa6c35db9f1334e37f38a2be7cc4bba0a4b Mon Sep 17 00:00:00 2001 From: GiovanniCardamone Date: Fri, 2 Dec 2022 23:30:45 +0100 Subject: [PATCH] test: dir parameters --- tests/options.test.ts | 4 ++-- tests/routes.test.ts | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/options.test.ts b/tests/options.test.ts index 67ea306..79fa779 100644 --- a/tests/options.test.ts +++ b/tests/options.test.ts @@ -30,7 +30,7 @@ describe('Options', () => { ) }) - test('ivalid dir parameters', (done) => { + test('invalid dir parameters', (done) => { const server = fastify() // @ts-expect-error not valid 33 as dir @@ -45,7 +45,7 @@ describe('Options', () => { }, (error, res) => { console.log({ error, res }) - expect(error.constructor.name).toBe('NodeError') + expect(error).not.toBe(undefined) done() } ) diff --git a/tests/routes.test.ts b/tests/routes.test.ts index 8cd5f58..2c8d276 100644 --- a/tests/routes.test.ts +++ b/tests/routes.test.ts @@ -378,6 +378,29 @@ describe('Routes', () => { ) } ) - } - ) + }) + + test('expect route /status to work', (done) => { + const server = fastify() + + const dir = mock('routes', { + a: {'status.js': exampleGetRoute, } + }) + + server.register(autoroutes, { + dir + }) + + server.inject( + { + method: 'GET', + url: '/a/status', + }, + (err, res) => { + expect(err).toBe(null) + expect(res.payload).toBe('get') + done() + } + ) + }) })