@tsed/platform-test-sdk 7.62.1 → 7.62.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/cjs/index.js +2 -1
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/tests/exports.js +4 -2
  4. package/lib/cjs/tests/exports.js.map +1 -1
  5. package/lib/cjs/tests/testBodyParams.js +22 -1
  6. package/lib/cjs/tests/testBodyParams.js.map +1 -1
  7. package/lib/cjs/tests/testCache.js +13 -3
  8. package/lib/cjs/tests/testCache.js.map +1 -1
  9. package/lib/cjs/tests/testDeepQueryParams.js +144 -0
  10. package/lib/cjs/tests/testDeepQueryParams.js.map +1 -0
  11. package/lib/cjs/tests/testErrors.js +1 -1
  12. package/lib/cjs/tests/testErrors.js.map +1 -1
  13. package/lib/cjs/tests/testHeaderParams.js +1 -0
  14. package/lib/cjs/tests/testHeaderParams.js.map +1 -1
  15. package/lib/cjs/tests/testInheritanceController.js +68 -3
  16. package/lib/cjs/tests/testInheritanceController.js.map +1 -1
  17. package/lib/cjs/tests/testQueryParams.js +1 -114
  18. package/lib/cjs/tests/testQueryParams.js.map +1 -1
  19. package/lib/cjs/tests/testResponse.js +0 -38
  20. package/lib/cjs/tests/testResponse.js.map +1 -1
  21. package/lib/cjs/tests/testStream.js +67 -0
  22. package/lib/cjs/tests/testStream.js.map +1 -0
  23. package/lib/esm/index.js +2 -1
  24. package/lib/esm/index.js.map +1 -1
  25. package/lib/esm/tests/exports.js +4 -2
  26. package/lib/esm/tests/exports.js.map +1 -1
  27. package/lib/esm/tests/testBodyParams.js +23 -2
  28. package/lib/esm/tests/testBodyParams.js.map +1 -1
  29. package/lib/esm/tests/testCache.js +13 -3
  30. package/lib/esm/tests/testCache.js.map +1 -1
  31. package/lib/esm/tests/testDeepQueryParams.js +140 -0
  32. package/lib/esm/tests/testDeepQueryParams.js.map +1 -0
  33. package/lib/esm/tests/testErrors.js +1 -1
  34. package/lib/esm/tests/testErrors.js.map +1 -1
  35. package/lib/esm/tests/testHeaderParams.js +1 -0
  36. package/lib/esm/tests/testHeaderParams.js.map +1 -1
  37. package/lib/esm/tests/testInheritanceController.js +67 -3
  38. package/lib/esm/tests/testInheritanceController.js.map +1 -1
  39. package/lib/esm/tests/testQueryParams.js +2 -115
  40. package/lib/esm/tests/testQueryParams.js.map +1 -1
  41. package/lib/esm/tests/testResponse.js +1 -39
  42. package/lib/esm/tests/testResponse.js.map +1 -1
  43. package/lib/esm/tests/testStream.js +63 -0
  44. package/lib/esm/tests/testStream.js.map +1 -0
  45. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/lib/types/index.d.ts +2 -1
  48. package/lib/types/tests/testDeepQueryParams.d.ts +3 -0
  49. package/lib/types/tests/testInheritanceController.d.ts +14 -0
  50. package/lib/types/tests/testStream.d.ts +2 -0
  51. package/package.json +13 -13
  52. package/src/index.ts +2 -1
  53. package/src/tests/exports.ts +4 -2
  54. package/src/tests/testBodyParams.ts +30 -7
  55. package/src/tests/testCache.ts +15 -6
  56. package/src/tests/testDeepQueryParams.ts +119 -0
  57. package/src/tests/testErrors.ts +1 -1
  58. package/src/tests/testHeaderParams.ts +1 -0
  59. package/src/tests/testInheritanceController.ts +47 -3
  60. package/src/tests/testQueryParams.ts +2 -93
  61. package/src/tests/testResponse.ts +2 -35
  62. package/src/tests/testStream.ts +60 -0
  63. package/lib/cjs/tests/testCtrlInheritance.js +0 -161
  64. package/lib/cjs/tests/testCtrlInheritance.js.map +0 -1
  65. package/lib/esm/tests/testCtrlInheritance.js +0 -156
  66. package/lib/esm/tests/testCtrlInheritance.js.map +0 -1
  67. package/lib/types/tests/testCtrlInheritance.d.ts +0 -18
  68. package/src/tests/testCtrlInheritance.ts +0 -140
@@ -0,0 +1,60 @@
1
+ import {Controller, Get, PlatformTest} from "@tsed/common";
2
+ import {ContentType} from "@tsed/schema";
3
+ import filedirname from "filedirname";
4
+ import {createReadStream} from "fs";
5
+ import {join} from "path";
6
+ import SuperTest from "supertest";
7
+ import {PlatformTestingSdkOpts} from "../interfaces";
8
+ // FIXME remove when esm is ready
9
+ const [, rootDir] = filedirname();
10
+
11
+ @Controller("/stream")
12
+ class TestStreamCtrl {
13
+ @Get("/scenario1")
14
+ @ContentType("application/json")
15
+ testScenario1() {
16
+ return createReadStream(join(rootDir, "../data/response.data.json"), "utf-8");
17
+ }
18
+
19
+ @Get("/scenario1b")
20
+ @ContentType("application/json")
21
+ testScenario2() {
22
+ return Promise.resolve(createReadStream(join(rootDir, "../data/response.data.json"), "utf-8"));
23
+ }
24
+ }
25
+
26
+ export function testStream(options: PlatformTestingSdkOpts) {
27
+ let request: SuperTest.Agent;
28
+
29
+ beforeAll(
30
+ PlatformTest.bootstrap(options.server, {
31
+ ...options,
32
+ mount: {
33
+ "/rest": [TestStreamCtrl]
34
+ }
35
+ })
36
+ );
37
+ beforeAll(() => {
38
+ request = SuperTest(PlatformTest.callback());
39
+ });
40
+ afterAll(PlatformTest.reset);
41
+
42
+ describe("Scenario1: when endpoint return a stream", () => {
43
+ describe("GET /rest/stream/scenario1", () => {
44
+ it("should return a body", async () => {
45
+ const response = await request.get("/rest/stream/scenario1");
46
+
47
+ expect(response.headers["content-type"]).toContain("application/json");
48
+ expect(response.body).toEqual({id: "1"});
49
+ });
50
+ });
51
+
52
+ describe("GET /rest/stream/scenario1b", () => {
53
+ it("should return a body", async () => {
54
+ const response = await request.get("/rest/stream/scenario1b");
55
+
56
+ expect(response.body).toEqual({id: "1"});
57
+ });
58
+ });
59
+ });
60
+ }
@@ -1,161 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.testCtrlInheritance = exports.TestChildController = exports.TestBaseController = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const schema_1 = require("@tsed/schema");
7
- const supertest_1 = tslib_1.__importDefault(require("supertest"));
8
- class TestBaseController {
9
- scenario1(search) {
10
- return {
11
- search
12
- };
13
- }
14
- scenario3(q) {
15
- return { data: q };
16
- }
17
- }
18
- tslib_1.__decorate([
19
- (0, common_1.Get)("/"),
20
- tslib_1.__param(0, (0, common_1.QueryParams)("search")),
21
- tslib_1.__metadata("design:type", Function),
22
- tslib_1.__metadata("design:paramtypes", [String]),
23
- tslib_1.__metadata("design:returntype", void 0)
24
- ], TestBaseController.prototype, "scenario1", null);
25
- tslib_1.__decorate([
26
- (0, common_1.Get)("/override"),
27
- tslib_1.__param(0, (0, common_1.QueryParams)("q")),
28
- tslib_1.__metadata("design:type", Function),
29
- tslib_1.__metadata("design:paramtypes", [String]),
30
- tslib_1.__metadata("design:returntype", void 0)
31
- ], TestBaseController.prototype, "scenario3", null);
32
- exports.TestBaseController = TestBaseController;
33
- let TestChildController = class TestChildController extends TestBaseController {
34
- scenario2(id) {
35
- return { id };
36
- }
37
- scenario3(s) {
38
- return { data: s };
39
- }
40
- };
41
- tslib_1.__decorate([
42
- (0, common_1.Get)("/:id"),
43
- tslib_1.__param(0, (0, common_1.PathParams)("id")),
44
- tslib_1.__metadata("design:type", Function),
45
- tslib_1.__metadata("design:paramtypes", [String]),
46
- tslib_1.__metadata("design:returntype", void 0)
47
- ], TestChildController.prototype, "scenario2", null);
48
- tslib_1.__decorate([
49
- (0, common_1.Get)("/override"),
50
- tslib_1.__param(0, (0, common_1.QueryParams)("s")),
51
- tslib_1.__metadata("design:type", Function),
52
- tslib_1.__metadata("design:paramtypes", [String]),
53
- tslib_1.__metadata("design:returntype", void 0)
54
- ], TestChildController.prototype, "scenario3", null);
55
- TestChildController = tslib_1.__decorate([
56
- (0, common_1.Controller)("/test")
57
- ], TestChildController);
58
- exports.TestChildController = TestChildController;
59
- function testCtrlInheritance(options) {
60
- let request;
61
- beforeAll(common_1.PlatformTest.bootstrap(options.server, {
62
- ...options,
63
- mount: {
64
- "/rest": [TestChildController]
65
- }
66
- }));
67
- beforeAll(() => {
68
- request = (0, supertest_1.default)(common_1.PlatformTest.callback());
69
- });
70
- afterAll(common_1.PlatformTest.reset);
71
- it("Scenario1: should call inherited method", async () => {
72
- const { body } = await request.get("/rest/test/?search=test").expect(200);
73
- expect(body).toEqual({
74
- search: "test"
75
- });
76
- });
77
- it("Scenario2: should the Child method", async () => {
78
- const { body } = await request.get("/rest/test/1").expect(200);
79
- expect(body).toEqual({ id: "1" });
80
- });
81
- it("Scenario2: should call the Child method and not the base method", async () => {
82
- const { body } = await request.get("/rest/test/1").expect(200);
83
- expect(body).toEqual({ id: "1" });
84
- });
85
- it("should generate swagger json", () => {
86
- expect((0, schema_1.getSpec)(TestChildController, { specType: schema_1.SpecTypes.OPENAPI })).toEqual({
87
- paths: {
88
- "/test": {
89
- get: {
90
- operationId: "testBaseControllerScenario1",
91
- parameters: [
92
- {
93
- in: "query",
94
- name: "search",
95
- required: false,
96
- schema: {
97
- type: "string"
98
- }
99
- }
100
- ],
101
- responses: {
102
- "200": {
103
- description: "Success"
104
- }
105
- },
106
- tags: ["TestChildController"]
107
- }
108
- },
109
- "/test/override": {
110
- get: {
111
- operationId: "testChildControllerScenario3",
112
- parameters: [
113
- {
114
- in: "query",
115
- name: "s",
116
- required: false,
117
- schema: {
118
- type: "string"
119
- }
120
- }
121
- ],
122
- responses: {
123
- "200": {
124
- description: "Success"
125
- }
126
- },
127
- tags: ["TestChildController"]
128
- }
129
- },
130
- "/test/{id}": {
131
- get: {
132
- operationId: "testChildControllerScenario2",
133
- parameters: [
134
- {
135
- in: "path",
136
- name: "id",
137
- required: true,
138
- schema: {
139
- type: "string"
140
- }
141
- }
142
- ],
143
- responses: {
144
- "200": {
145
- description: "Success"
146
- }
147
- },
148
- tags: ["TestChildController"]
149
- }
150
- }
151
- },
152
- tags: [
153
- {
154
- name: "TestChildController"
155
- }
156
- ]
157
- });
158
- });
159
- }
160
- exports.testCtrlInheritance = testCtrlInheritance;
161
- //# sourceMappingURL=testCtrlInheritance.js.map
@@ -1 +0,0 @@
1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,156 +0,0 @@
1
- import { __decorate, __metadata, __param } from "tslib";
2
- import { Controller, Get, PathParams, PlatformTest, QueryParams } from "@tsed/common";
3
- import { getSpec, SpecTypes } from "@tsed/schema";
4
- import SuperTest from "supertest";
5
- export class TestBaseController {
6
- scenario1(search) {
7
- return {
8
- search
9
- };
10
- }
11
- scenario3(q) {
12
- return { data: q };
13
- }
14
- }
15
- __decorate([
16
- Get("/"),
17
- __param(0, QueryParams("search")),
18
- __metadata("design:type", Function),
19
- __metadata("design:paramtypes", [String]),
20
- __metadata("design:returntype", void 0)
21
- ], TestBaseController.prototype, "scenario1", null);
22
- __decorate([
23
- Get("/override"),
24
- __param(0, QueryParams("q")),
25
- __metadata("design:type", Function),
26
- __metadata("design:paramtypes", [String]),
27
- __metadata("design:returntype", void 0)
28
- ], TestBaseController.prototype, "scenario3", null);
29
- let TestChildController = class TestChildController extends TestBaseController {
30
- scenario2(id) {
31
- return { id };
32
- }
33
- scenario3(s) {
34
- return { data: s };
35
- }
36
- };
37
- __decorate([
38
- Get("/:id"),
39
- __param(0, PathParams("id")),
40
- __metadata("design:type", Function),
41
- __metadata("design:paramtypes", [String]),
42
- __metadata("design:returntype", void 0)
43
- ], TestChildController.prototype, "scenario2", null);
44
- __decorate([
45
- Get("/override"),
46
- __param(0, QueryParams("s")),
47
- __metadata("design:type", Function),
48
- __metadata("design:paramtypes", [String]),
49
- __metadata("design:returntype", void 0)
50
- ], TestChildController.prototype, "scenario3", null);
51
- TestChildController = __decorate([
52
- Controller("/test")
53
- ], TestChildController);
54
- export { TestChildController };
55
- export function testCtrlInheritance(options) {
56
- let request;
57
- beforeAll(PlatformTest.bootstrap(options.server, {
58
- ...options,
59
- mount: {
60
- "/rest": [TestChildController]
61
- }
62
- }));
63
- beforeAll(() => {
64
- request = SuperTest(PlatformTest.callback());
65
- });
66
- afterAll(PlatformTest.reset);
67
- it("Scenario1: should call inherited method", async () => {
68
- const { body } = await request.get("/rest/test/?search=test").expect(200);
69
- expect(body).toEqual({
70
- search: "test"
71
- });
72
- });
73
- it("Scenario2: should the Child method", async () => {
74
- const { body } = await request.get("/rest/test/1").expect(200);
75
- expect(body).toEqual({ id: "1" });
76
- });
77
- it("Scenario2: should call the Child method and not the base method", async () => {
78
- const { body } = await request.get("/rest/test/1").expect(200);
79
- expect(body).toEqual({ id: "1" });
80
- });
81
- it("should generate swagger json", () => {
82
- expect(getSpec(TestChildController, { specType: SpecTypes.OPENAPI })).toEqual({
83
- paths: {
84
- "/test": {
85
- get: {
86
- operationId: "testBaseControllerScenario1",
87
- parameters: [
88
- {
89
- in: "query",
90
- name: "search",
91
- required: false,
92
- schema: {
93
- type: "string"
94
- }
95
- }
96
- ],
97
- responses: {
98
- "200": {
99
- description: "Success"
100
- }
101
- },
102
- tags: ["TestChildController"]
103
- }
104
- },
105
- "/test/override": {
106
- get: {
107
- operationId: "testChildControllerScenario3",
108
- parameters: [
109
- {
110
- in: "query",
111
- name: "s",
112
- required: false,
113
- schema: {
114
- type: "string"
115
- }
116
- }
117
- ],
118
- responses: {
119
- "200": {
120
- description: "Success"
121
- }
122
- },
123
- tags: ["TestChildController"]
124
- }
125
- },
126
- "/test/{id}": {
127
- get: {
128
- operationId: "testChildControllerScenario2",
129
- parameters: [
130
- {
131
- in: "path",
132
- name: "id",
133
- required: true,
134
- schema: {
135
- type: "string"
136
- }
137
- }
138
- ],
139
- responses: {
140
- "200": {
141
- description: "Success"
142
- }
143
- },
144
- tags: ["TestChildController"]
145
- }
146
- }
147
- },
148
- tags: [
149
- {
150
- name: "TestChildController"
151
- }
152
- ]
153
- });
154
- });
155
- }
156
- //# sourceMappingURL=testCtrlInheritance.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testCtrlInheritance.js","sourceRoot":"","sources":["../../../src/tests/testCtrlInheritance.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACpF,OAAO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EAAE,OAAO;gCACX,IAAI,EAAE,QAAQ;gCACd,QAAQ,EAAE,KAAK;gCACf,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;iCACf;6BACF;yBACF;wBACD,SAAS,EAAE;4BACT,KAAK,EAAE;gCACL,WAAW,EAAE,SAAS;6BACvB;yBACF;wBACD,IAAI,EAAE,CAAC,qBAAqB,CAAC;qBAC9B;iBACF;gBACD,gBAAgB,EAAE;oBAChB,GAAG,EAAE;wBACH,WAAW,EAAE,8BAA8B;wBAC3C,UAAU,EAAE;4BACV;gCACE,EAAE,EAAE,OAAO;gCACX,IAAI,EAAE,GAAG;gCACT,QAAQ,EAAE,KAAK;gCACf,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;iCACf;6BACF;yBACF;wBACD,SAAS,EAAE;4BACT,KAAK,EAAE;gCACL,WAAW,EAAE,SAAS;6BACvB;yBACF;wBACD,IAAI,EAAE,CAAC,qBAAqB,CAAC;qBAC9B;iBACF;gBACD,YAAY,EAAE;oBACZ,GAAG,EAAE;wBACH,WAAW,EAAE,8BAA8B;wBAC3C,UAAU,EAAE;4BACV;gCACE,EAAE,EAAE,MAAM;gCACV,IAAI,EAAE,IAAI;gCACV,QAAQ,EAAE,IAAI;gCACd,MAAM,EAAE;oCACN,IAAI,EAAE,QAAQ;iCACf;6BACF;yBACF;wBACD,SAAS,EAAE;4BACT,KAAK,EAAE;gCACL,WAAW,EAAE,SAAS;6BACvB;yBACF;wBACD,IAAI,EAAE,CAAC,qBAAqB,CAAC;qBAC9B;iBACF;aACF;YACD,IAAI,EAAE;gBACJ;oBACE,IAAI,EAAE,qBAAqB;iBAC5B;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,18 +0,0 @@
1
- import { PlatformTestingSdkOpts } from "../interfaces";
2
- export declare abstract class TestBaseController {
3
- scenario1(search: string): {
4
- search: string;
5
- };
6
- scenario3(q: string): {
7
- data: string;
8
- };
9
- }
10
- export declare class TestChildController extends TestBaseController {
11
- scenario2(id: string): {
12
- id: string;
13
- };
14
- scenario3(s: string): {
15
- data: string;
16
- };
17
- }
18
- export declare function testCtrlInheritance(options: PlatformTestingSdkOpts): void;
@@ -1,140 +0,0 @@
1
- import {Controller, Get, PathParams, PlatformTest, QueryParams} from "@tsed/common";
2
- import {getSpec, SpecTypes} from "@tsed/schema";
3
- import SuperTest from "supertest";
4
- import {PlatformTestingSdkOpts} from "../interfaces";
5
-
6
- export abstract class TestBaseController {
7
- @Get("/")
8
- scenario1(@QueryParams("search") search: string) {
9
- return {
10
- search
11
- };
12
- }
13
-
14
- @Get("/override")
15
- scenario3(@QueryParams("q") q: string) {
16
- return {data: q};
17
- }
18
- }
19
-
20
- @Controller("/test")
21
- export class TestChildController extends TestBaseController {
22
- @Get("/:id")
23
- scenario2(@PathParams("id") id: string) {
24
- return {id};
25
- }
26
-
27
- @Get("/override")
28
- scenario3(@QueryParams("s") s: string) {
29
- return {data: s};
30
- }
31
- }
32
-
33
- export function testCtrlInheritance(options: PlatformTestingSdkOpts) {
34
- let request: SuperTest.Agent;
35
-
36
- beforeAll(
37
- PlatformTest.bootstrap(options.server, {
38
- ...options,
39
- mount: {
40
- "/rest": [TestChildController]
41
- }
42
- })
43
- );
44
- beforeAll(() => {
45
- request = SuperTest(PlatformTest.callback());
46
- });
47
- afterAll(PlatformTest.reset);
48
-
49
- it("Scenario1: should call inherited method", async () => {
50
- const {body} = await request.get("/rest/test/?search=test").expect(200);
51
- expect(body).toEqual({
52
- search: "test"
53
- });
54
- });
55
-
56
- it("Scenario2: should the Child method", async () => {
57
- const {body} = await request.get("/rest/test/1").expect(200);
58
- expect(body).toEqual({id: "1"});
59
- });
60
-
61
- it("Scenario2: should call the Child method and not the base method", async () => {
62
- const {body} = await request.get("/rest/test/1").expect(200);
63
- expect(body).toEqual({id: "1"});
64
- });
65
-
66
- it("should generate swagger json", () => {
67
- expect(getSpec(TestChildController, {specType: SpecTypes.OPENAPI})).toEqual({
68
- paths: {
69
- "/test": {
70
- get: {
71
- operationId: "testBaseControllerScenario1",
72
- parameters: [
73
- {
74
- in: "query",
75
- name: "search",
76
- required: false,
77
- schema: {
78
- type: "string"
79
- }
80
- }
81
- ],
82
- responses: {
83
- "200": {
84
- description: "Success"
85
- }
86
- },
87
- tags: ["TestChildController"]
88
- }
89
- },
90
- "/test/override": {
91
- get: {
92
- operationId: "testChildControllerScenario3",
93
- parameters: [
94
- {
95
- in: "query",
96
- name: "s",
97
- required: false,
98
- schema: {
99
- type: "string"
100
- }
101
- }
102
- ],
103
- responses: {
104
- "200": {
105
- description: "Success"
106
- }
107
- },
108
- tags: ["TestChildController"]
109
- }
110
- },
111
- "/test/{id}": {
112
- get: {
113
- operationId: "testChildControllerScenario2",
114
- parameters: [
115
- {
116
- in: "path",
117
- name: "id",
118
- required: true,
119
- schema: {
120
- type: "string"
121
- }
122
- }
123
- ],
124
- responses: {
125
- "200": {
126
- description: "Success"
127
- }
128
- },
129
- tags: ["TestChildController"]
130
- }
131
- }
132
- },
133
- tags: [
134
- {
135
- name: "TestChildController"
136
- }
137
- ]
138
- });
139
- });
140
- }