-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcontroller.test.ts
36 lines (28 loc) · 1.02 KB
/
controller.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2020 Liam Tan. All rights reserved. MIT license.
import { assertEquals } from "./deps.ts";
import { Controller } from "./controller.ts";
import { getControllerOwnMeta } from "./metadata.ts";
import { ControllerMetadata } from "./types.ts";
Deno.test({
name: "Controller sets metadata on class",
fn(): void {
const prefix: string = "/";
@Controller(prefix)
class TestClass {}
const meta: ControllerMetadata | undefined = getControllerOwnMeta(TestClass);
assertEquals(meta?.prefix, prefix);
assertEquals(meta?.defaultResponseCodes instanceof Map, true);
assertEquals(meta?.routes instanceof Map, true);
assertEquals(meta?.args instanceof Array, true);
},
});
Deno.test({
name: "Controller sets default prefix on class when no prefix arg is specified",
fn(): void {
const defaultPrefix: string = "/";
@Controller()
class TestClass {}
const meta: ControllerMetadata | undefined = getControllerOwnMeta(TestClass);
assertEquals(meta?.prefix, defaultPrefix);
},
});