-
-
Notifications
You must be signed in to change notification settings - Fork 281
/
returns.spec.ts
82 lines (77 loc) · 2.16 KB
/
returns.spec.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {Store} from "@tsed/core";
import {descriptorOf} from "@tsed/core";
import {Returns} from "../../../../packages/swagger/src/decorators/returns";
import {expect} from "chai";
class Test {
test1() {}
test2() {}
test3() {}
test4() {}
}
describe("Returns()", () => {
describe("when status and configuration are given", () => {
before(() => {
Returns(400, {
description: "Bad Request"
})(Test, "test1", descriptorOf(Test, "test1"));
this.store = Store.fromMethod(Test, "test1");
});
it("should set the responses", () => {
expect(this.store.get("responses")).to.deep.eq({
"400": {
collectionType: undefined,
description: "Bad Request",
headers: undefined,
type: undefined
}
});
});
});
describe("when a type and configuration are given", () => {
before(() => {
Returns(Test, {
description: "Success"
})(Test, "test2", descriptorOf(Test, "test2"));
this.store = Store.fromMethod(Test, "test2");
});
it("should set the responses", () => {
expect(this.store.get("response")).to.deep.eq({
collectionType: undefined,
description: "Success",
headers: undefined,
type: Test
});
});
});
describe("when a type is given", () => {
before(() => {
Returns(Test)(Test, "test3", descriptorOf(Test, "test3"));
this.store = Store.fromMethod(Test, "test3");
});
it("should set the responses", () => {
expect(this.store.get("response")).to.deep.eq({
collectionType: undefined,
description: undefined,
headers: undefined,
type: Test
});
});
});
describe("when a configuration is given", () => {
before(() => {
Returns({
description: "Success",
type: Test
})(Test, "test4", descriptorOf(Test, "test4"));
this.store = Store.fromMethod(Test, "test4");
});
it("should set the responses", () => {
expect(this.store.get("response")).to.deep.eq({
collectionType: undefined,
description: "Success",
headers: undefined,
type: Test
});
});
});
});