Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 22b9f74

Browse files
committed
test(createrest-koa): Test createKoaRouter
1 parent 50a72e2 commit 22b9f74

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

packages/createrest-koa/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { flattenRoutes, isCreateRestInstance } from 'createrest'
44

55
export function createKoaRouter(routing) {
66
if (!isCreateRestInstance(routing)) {
7-
throw new Error('You can create koa middleware only from createRest routes')
7+
throw new TypeError('You can create koa middleware only from createRest routes')
88
}
99

1010
const router = new Router()

packages/createrest-koa/test/index.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ test('deep path in simple handlers throws', async (t) => {
7070
})
7171
})
7272

73+
test('throws when passed not routes', async (t) => {
74+
t.throws(() => {
75+
createKoaRouter(() => {})
76+
}, TypeError)
77+
78+
t.throws(() => {
79+
createKoaRouter({})
80+
}, TypeError)
81+
})
82+
7383

7484
test('deep scopes works', async (t) => {
7585
t.plan(5)

0 commit comments

Comments
 (0)