Skip to content

Commit

Permalink
test: dir parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniCardamone committed Dec 2, 2022
1 parent 4697a46 commit 0c522fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +45,7 @@ describe('Options', () => {
},
(error, res) => {
console.log({ error, res })
expect(error.constructor.name).toBe('NodeError')
expect(error).not.toBe(undefined)
done()
}
)
Expand Down
27 changes: 25 additions & 2 deletions tests/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
)
})
})

0 comments on commit 0c522fa

Please sign in to comment.