@tsed/platform-test-sdk 7.12.0
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.
- package/lib/cjs/components/PlatformTestSdk.js +31 -0
- package/lib/cjs/components/PlatformTestSdk.js.map +1 -0
- package/lib/cjs/data/swagger.json +32 -0
- package/lib/cjs/errors/CustomBadRequest.js +18 -0
- package/lib/cjs/errors/CustomBadRequest.js.map +1 -0
- package/lib/cjs/errors/CustomInternalError.js +18 -0
- package/lib/cjs/errors/CustomInternalError.js.map +1 -0
- package/lib/cjs/index.js +42 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/PlatformTestingSdkOpts.js +3 -0
- package/lib/cjs/interfaces/PlatformTestingSdkOpts.js.map +1 -0
- package/lib/cjs/interfaces/index.js +8 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/cjs/modules/feature/FeatureModule.js +17 -0
- package/lib/cjs/modules/feature/FeatureModule.js.map +1 -0
- package/lib/cjs/modules/feature/controllers/FeatureController.js +23 -0
- package/lib/cjs/modules/feature/controllers/FeatureController.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/tests/exports.js +66 -0
- package/lib/cjs/tests/exports.js.map +1 -0
- package/lib/cjs/tests/testAcceptMime.js +103 -0
- package/lib/cjs/tests/testAcceptMime.js.map +1 -0
- package/lib/cjs/tests/testAuth.js +343 -0
- package/lib/cjs/tests/testAuth.js.map +1 -0
- package/lib/cjs/tests/testBodyParams.js +526 -0
- package/lib/cjs/tests/testBodyParams.js.map +1 -0
- package/lib/cjs/tests/testCache.js +292 -0
- package/lib/cjs/tests/testCache.js.map +1 -0
- package/lib/cjs/tests/testChildrenControllers.js +64 -0
- package/lib/cjs/tests/testChildrenControllers.js.map +1 -0
- package/lib/cjs/tests/testCookies.js +45 -0
- package/lib/cjs/tests/testCookies.js.map +1 -0
- package/lib/cjs/tests/testCtrlInheritance.js +161 -0
- package/lib/cjs/tests/testCtrlInheritance.js.map +1 -0
- package/lib/cjs/tests/testCustom404.js +32 -0
- package/lib/cjs/tests/testCustom404.js.map +1 -0
- package/lib/cjs/tests/testErrors.js +252 -0
- package/lib/cjs/tests/testErrors.js.map +1 -0
- package/lib/cjs/tests/testHandlers.js +110 -0
- package/lib/cjs/tests/testHandlers.js.map +1 -0
- package/lib/cjs/tests/testHeaderParams.js +166 -0
- package/lib/cjs/tests/testHeaderParams.js.map +1 -0
- package/lib/cjs/tests/testHeaders.js +101 -0
- package/lib/cjs/tests/testHeaders.js.map +1 -0
- package/lib/cjs/tests/testInheritanceController.js +173 -0
- package/lib/cjs/tests/testInheritanceController.js.map +1 -0
- package/lib/cjs/tests/testLocals.js +63 -0
- package/lib/cjs/tests/testLocals.js.map +1 -0
- package/lib/cjs/tests/testLocation.js +42 -0
- package/lib/cjs/tests/testLocation.js.map +1 -0
- package/lib/cjs/tests/testMiddlewares.js +210 -0
- package/lib/cjs/tests/testMiddlewares.js.map +1 -0
- package/lib/cjs/tests/testModule.js +49 -0
- package/lib/cjs/tests/testModule.js.map +1 -0
- package/lib/cjs/tests/testMulter.js +162 -0
- package/lib/cjs/tests/testMulter.js.map +1 -0
- package/lib/cjs/tests/testPathParams.js +142 -0
- package/lib/cjs/tests/testPathParams.js.map +1 -0
- package/lib/cjs/tests/testQueryParams.js +354 -0
- package/lib/cjs/tests/testQueryParams.js.map +1 -0
- package/lib/cjs/tests/testRedirect.js +143 -0
- package/lib/cjs/tests/testRedirect.js.map +1 -0
- package/lib/cjs/tests/testResponse.js +622 -0
- package/lib/cjs/tests/testResponse.js.map +1 -0
- package/lib/cjs/tests/testResponseFilter.js +107 -0
- package/lib/cjs/tests/testResponseFilter.js.map +1 -0
- package/lib/cjs/tests/testRouting.js +75 -0
- package/lib/cjs/tests/testRouting.js.map +1 -0
- package/lib/cjs/tests/testScopeRequest.js +116 -0
- package/lib/cjs/tests/testScopeRequest.js.map +1 -0
- package/lib/cjs/tests/testSession.js +128 -0
- package/lib/cjs/tests/testSession.js.map +1 -0
- package/lib/cjs/tests/testStatics.js +58 -0
- package/lib/cjs/tests/testStatics.js.map +1 -0
- package/lib/cjs/tests/testView.js +83 -0
- package/lib/cjs/tests/testView.js.map +1 -0
- package/lib/esm/components/PlatformTestSdk.js +27 -0
- package/lib/esm/components/PlatformTestSdk.js.map +1 -0
- package/lib/esm/data/swagger.json +32 -0
- package/lib/esm/errors/CustomBadRequest.js +14 -0
- package/lib/esm/errors/CustomBadRequest.js.map +1 -0
- package/lib/esm/errors/CustomInternalError.js +14 -0
- package/lib/esm/errors/CustomInternalError.js.map +1 -0
- package/lib/esm/index.js +39 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/PlatformTestingSdkOpts.js +2 -0
- package/lib/esm/interfaces/PlatformTestingSdkOpts.js.map +1 -0
- package/lib/esm/interfaces/index.js +5 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/modules/feature/FeatureModule.js +14 -0
- package/lib/esm/modules/feature/FeatureModule.js.map +1 -0
- package/lib/esm/modules/feature/controllers/FeatureController.js +20 -0
- package/lib/esm/modules/feature/controllers/FeatureController.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/tests/exports.js +63 -0
- package/lib/esm/tests/exports.js.map +1 -0
- package/lib/esm/tests/testAcceptMime.js +99 -0
- package/lib/esm/tests/testAcceptMime.js.map +1 -0
- package/lib/esm/tests/testAuth.js +338 -0
- package/lib/esm/tests/testAuth.js.map +1 -0
- package/lib/esm/tests/testBodyParams.js +522 -0
- package/lib/esm/tests/testBodyParams.js.map +1 -0
- package/lib/esm/tests/testCache.js +288 -0
- package/lib/esm/tests/testCache.js.map +1 -0
- package/lib/esm/tests/testChildrenControllers.js +60 -0
- package/lib/esm/tests/testChildrenControllers.js.map +1 -0
- package/lib/esm/tests/testCookies.js +41 -0
- package/lib/esm/tests/testCookies.js.map +1 -0
- package/lib/esm/tests/testCtrlInheritance.js +156 -0
- package/lib/esm/tests/testCtrlInheritance.js.map +1 -0
- package/lib/esm/tests/testCustom404.js +27 -0
- package/lib/esm/tests/testCustom404.js.map +1 -0
- package/lib/esm/tests/testErrors.js +248 -0
- package/lib/esm/tests/testErrors.js.map +1 -0
- package/lib/esm/tests/testHandlers.js +105 -0
- package/lib/esm/tests/testHandlers.js.map +1 -0
- package/lib/esm/tests/testHeaderParams.js +162 -0
- package/lib/esm/tests/testHeaderParams.js.map +1 -0
- package/lib/esm/tests/testHeaders.js +97 -0
- package/lib/esm/tests/testHeaders.js.map +1 -0
- package/lib/esm/tests/testInheritanceController.js +167 -0
- package/lib/esm/tests/testInheritanceController.js.map +1 -0
- package/lib/esm/tests/testLocals.js +59 -0
- package/lib/esm/tests/testLocals.js.map +1 -0
- package/lib/esm/tests/testLocation.js +38 -0
- package/lib/esm/tests/testLocation.js.map +1 -0
- package/lib/esm/tests/testMiddlewares.js +206 -0
- package/lib/esm/tests/testMiddlewares.js.map +1 -0
- package/lib/esm/tests/testModule.js +45 -0
- package/lib/esm/tests/testModule.js.map +1 -0
- package/lib/esm/tests/testMulter.js +156 -0
- package/lib/esm/tests/testMulter.js.map +1 -0
- package/lib/esm/tests/testPathParams.js +138 -0
- package/lib/esm/tests/testPathParams.js.map +1 -0
- package/lib/esm/tests/testQueryParams.js +349 -0
- package/lib/esm/tests/testQueryParams.js.map +1 -0
- package/lib/esm/tests/testRedirect.js +139 -0
- package/lib/esm/tests/testRedirect.js.map +1 -0
- package/lib/esm/tests/testResponse.js +615 -0
- package/lib/esm/tests/testResponse.js.map +1 -0
- package/lib/esm/tests/testResponseFilter.js +103 -0
- package/lib/esm/tests/testResponseFilter.js.map +1 -0
- package/lib/esm/tests/testRouting.js +71 -0
- package/lib/esm/tests/testRouting.js.map +1 -0
- package/lib/esm/tests/testScopeRequest.js +112 -0
- package/lib/esm/tests/testScopeRequest.js.map +1 -0
- package/lib/esm/tests/testSession.js +122 -0
- package/lib/esm/tests/testSession.js.map +1 -0
- package/lib/esm/tests/testStatics.js +54 -0
- package/lib/esm/tests/testStatics.js.map +1 -0
- package/lib/esm/tests/testView.js +79 -0
- package/lib/esm/tests/testView.js.map +1 -0
- package/lib/types/components/PlatformTestSdk.d.ts +9 -0
- package/lib/types/errors/CustomBadRequest.d.ts +8 -0
- package/lib/types/errors/CustomInternalError.d.ts +8 -0
- package/lib/types/index.d.ts +38 -0
- package/lib/types/interfaces/PlatformTestingSdkOpts.d.ts +8 -0
- package/lib/types/interfaces/index.d.ts +4 -0
- package/lib/types/modules/feature/FeatureModule.d.ts +2 -0
- package/lib/types/modules/feature/controllers/FeatureController.d.ts +3 -0
- package/lib/types/tests/exports.d.ts +2 -0
- package/lib/types/tests/testAcceptMime.d.ts +2 -0
- package/lib/types/tests/testAuth.d.ts +8 -0
- package/lib/types/tests/testBodyParams.d.ts +3 -0
- package/lib/types/tests/testCache.d.ts +2 -0
- package/lib/types/tests/testChildrenControllers.d.ts +2 -0
- package/lib/types/tests/testCookies.d.ts +11 -0
- package/lib/types/tests/testCtrlInheritance.d.ts +18 -0
- package/lib/types/tests/testCustom404.d.ts +2 -0
- package/lib/types/tests/testErrors.d.ts +19 -0
- package/lib/types/tests/testHandlers.d.ts +12 -0
- package/lib/types/tests/testHeaderParams.d.ts +16 -0
- package/lib/types/tests/testHeaders.d.ts +8 -0
- package/lib/types/tests/testInheritanceController.d.ts +28 -0
- package/lib/types/tests/testLocals.d.ts +2 -0
- package/lib/types/tests/testLocation.d.ts +2 -0
- package/lib/types/tests/testMiddlewares.d.ts +8 -0
- package/lib/types/tests/testModule.d.ts +2 -0
- package/lib/types/tests/testMulter.d.ts +21 -0
- package/lib/types/tests/testPathParams.d.ts +2 -0
- package/lib/types/tests/testQueryParams.d.ts +6 -0
- package/lib/types/tests/testRedirect.d.ts +2 -0
- package/lib/types/tests/testResponse.d.ts +16 -0
- package/lib/types/tests/testResponseFilter.d.ts +2 -0
- package/lib/types/tests/testRouting.d.ts +7 -0
- package/lib/types/tests/testScopeRequest.d.ts +12 -0
- package/lib/types/tests/testSession.d.ts +16 -0
- package/lib/types/tests/testStatics.d.ts +2 -0
- package/lib/types/tests/testView.d.ts +2 -0
- package/package.json +44 -0
- package/src/components/PlatformTestSdk.ts +29 -0
- package/src/data/file.txt +1 -0
- package/src/data/response.data.json +3 -0
- package/src/data/swagger.json +32 -0
- package/src/errors/CustomBadRequest.ts +16 -0
- package/src/errors/CustomInternalError.ts +16 -0
- package/src/index.ts +39 -0
- package/src/interfaces/PlatformTestingSdkOpts.ts +10 -0
- package/src/interfaces/index.ts +5 -0
- package/src/modules/feature/FeatureModule.ts +9 -0
- package/src/modules/feature/controllers/FeatureController.ts +11 -0
- package/src/tests/exports.ts +69 -0
- package/src/tests/testAcceptMime.ts +95 -0
- package/src/tests/testAuth.ts +339 -0
- package/src/tests/testBodyParams.ts +455 -0
- package/src/tests/testCache.ts +270 -0
- package/src/tests/testChildrenControllers.ts +55 -0
- package/src/tests/testCookies.ts +36 -0
- package/src/tests/testCtrlInheritance.ts +140 -0
- package/src/tests/testCustom404.ts +33 -0
- package/src/tests/testErrors.ts +223 -0
- package/src/tests/testHandlers.ts +92 -0
- package/src/tests/testHeaderParams.ts +149 -0
- package/src/tests/testHeaders.ts +91 -0
- package/src/tests/testInheritanceController.ts +156 -0
- package/src/tests/testLocals.ts +46 -0
- package/src/tests/testLocation.ts +37 -0
- package/src/tests/testMiddlewares.ts +159 -0
- package/src/tests/testModule.ts +46 -0
- package/src/tests/testMulter.ts +140 -0
- package/src/tests/testPathParams.ts +122 -0
- package/src/tests/testQueryParams.ts +323 -0
- package/src/tests/testRedirect.ts +124 -0
- package/src/tests/testResponse.ts +558 -0
- package/src/tests/testResponseFilter.ts +101 -0
- package/src/tests/testRouting.ts +65 -0
- package/src/tests/testScopeRequest.ts +111 -0
- package/src/tests/testSession.ts +104 -0
- package/src/tests/testStatics.ts +61 -0
- package/src/tests/testView.ts +68 -0
- package/tsconfig.compile.esm.json +12 -0
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testResponse = exports.ModelGroup = exports.TestNestedEnum = exports.NestedEnum = exports.EnumValue = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@tsed/common");
|
|
6
|
+
const schema_1 = require("@tsed/schema");
|
|
7
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const rxjs_1 = require("rxjs");
|
|
11
|
+
const superagent_1 = require("superagent");
|
|
12
|
+
const supertest_1 = tslib_1.__importDefault(require("supertest"));
|
|
13
|
+
class Base {
|
|
14
|
+
ignoreMeBase;
|
|
15
|
+
fooBase;
|
|
16
|
+
}
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
(0, schema_1.Ignore)(),
|
|
19
|
+
tslib_1.__metadata("design:type", String)
|
|
20
|
+
], Base.prototype, "ignoreMeBase", void 0);
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, schema_1.Property)(),
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
24
|
+
], Base.prototype, "fooBase", void 0);
|
|
25
|
+
class MyModel extends Base {
|
|
26
|
+
foo;
|
|
27
|
+
ignoreMe;
|
|
28
|
+
ignoreMe2;
|
|
29
|
+
}
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, schema_1.Property)(),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], MyModel.prototype, "foo", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, schema_1.Ignore)(),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], MyModel.prototype, "ignoreMe", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, schema_1.Ignore)((value, ctx) => ctx.endpoint),
|
|
40
|
+
tslib_1.__metadata("design:type", String)
|
|
41
|
+
], MyModel.prototype, "ignoreMe2", void 0);
|
|
42
|
+
class EmptyModel {
|
|
43
|
+
raw;
|
|
44
|
+
affected;
|
|
45
|
+
}
|
|
46
|
+
var EnumValue;
|
|
47
|
+
(function (EnumValue) {
|
|
48
|
+
EnumValue["One"] = "one";
|
|
49
|
+
EnumValue["Two"] = "two";
|
|
50
|
+
})(EnumValue = exports.EnumValue || (exports.EnumValue = {}));
|
|
51
|
+
class NestedEnum {
|
|
52
|
+
value;
|
|
53
|
+
}
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, schema_1.Required)(),
|
|
56
|
+
(0, schema_1.Enum)(EnumValue),
|
|
57
|
+
tslib_1.__metadata("design:type", String)
|
|
58
|
+
], NestedEnum.prototype, "value", void 0);
|
|
59
|
+
exports.NestedEnum = NestedEnum;
|
|
60
|
+
class TestNestedEnum {
|
|
61
|
+
nested;
|
|
62
|
+
}
|
|
63
|
+
tslib_1.__decorate([
|
|
64
|
+
(0, schema_1.Property)(),
|
|
65
|
+
tslib_1.__metadata("design:type", NestedEnum)
|
|
66
|
+
], TestNestedEnum.prototype, "nested", void 0);
|
|
67
|
+
exports.TestNestedEnum = TestNestedEnum;
|
|
68
|
+
class ModelGroup {
|
|
69
|
+
id;
|
|
70
|
+
groups;
|
|
71
|
+
}
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, schema_1.Property)(),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], ModelGroup.prototype, "id", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, schema_1.Groups)("!creation"),
|
|
78
|
+
tslib_1.__metadata("design:type", String)
|
|
79
|
+
], ModelGroup.prototype, "groups", void 0);
|
|
80
|
+
exports.ModelGroup = ModelGroup;
|
|
81
|
+
class TeamModel {
|
|
82
|
+
name;
|
|
83
|
+
}
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, schema_1.Required)(),
|
|
86
|
+
(0, schema_1.Name)("teamName"),
|
|
87
|
+
tslib_1.__metadata("design:type", String)
|
|
88
|
+
], TeamModel.prototype, "name", void 0);
|
|
89
|
+
class TeamsModel {
|
|
90
|
+
teams;
|
|
91
|
+
}
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, schema_1.Required)(),
|
|
94
|
+
(0, schema_1.CollectionOf)(TeamModel),
|
|
95
|
+
(0, schema_1.ForwardGroups)(),
|
|
96
|
+
tslib_1.__metadata("design:type", Array)
|
|
97
|
+
], TeamsModel.prototype, "teams", void 0);
|
|
98
|
+
class AllowedModel {
|
|
99
|
+
id;
|
|
100
|
+
description;
|
|
101
|
+
prop1; // not display by default
|
|
102
|
+
prop2; // not display by default
|
|
103
|
+
sensitiveProp; // not displayed because it's a sensitive props
|
|
104
|
+
}
|
|
105
|
+
tslib_1.__decorate([
|
|
106
|
+
(0, schema_1.Property)(),
|
|
107
|
+
tslib_1.__metadata("design:type", String)
|
|
108
|
+
], AllowedModel.prototype, "id", void 0);
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, schema_1.Property)(),
|
|
111
|
+
tslib_1.__metadata("design:type", String)
|
|
112
|
+
], AllowedModel.prototype, "description", void 0);
|
|
113
|
+
tslib_1.__decorate([
|
|
114
|
+
(0, schema_1.Groups)("summary"),
|
|
115
|
+
tslib_1.__metadata("design:type", String)
|
|
116
|
+
], AllowedModel.prototype, "prop1", void 0);
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, schema_1.Groups)("details"),
|
|
119
|
+
tslib_1.__metadata("design:type", String)
|
|
120
|
+
], AllowedModel.prototype, "prop2", void 0);
|
|
121
|
+
tslib_1.__decorate([
|
|
122
|
+
(0, schema_1.Groups)("admin"),
|
|
123
|
+
tslib_1.__metadata("design:type", String)
|
|
124
|
+
], AllowedModel.prototype, "sensitiveProp", void 0);
|
|
125
|
+
let TestResponseParamsCtrl = class TestResponseParamsCtrl {
|
|
126
|
+
testScenario1Get(id) {
|
|
127
|
+
return `hello-${id}`;
|
|
128
|
+
}
|
|
129
|
+
testScenario3EmptyResponse(id, ctx) {
|
|
130
|
+
if (id) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
ctx.response.status(201);
|
|
134
|
+
return {
|
|
135
|
+
id: 1
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async testScenario5Promise() {
|
|
139
|
+
await new Promise((resolve) => {
|
|
140
|
+
resolve(undefined);
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
id: 1
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
testScenario6Observable() {
|
|
147
|
+
return (0, rxjs_1.of)({ id: 1 });
|
|
148
|
+
}
|
|
149
|
+
async testScenario6bObservable() {
|
|
150
|
+
return (0, rxjs_1.of)({ id: 1 });
|
|
151
|
+
}
|
|
152
|
+
testScenario7Stream() {
|
|
153
|
+
return (0, fs_1.createReadStream)((0, path_1.join)(__dirname, "../data/response.data.json"));
|
|
154
|
+
}
|
|
155
|
+
async testScenario7bStream() {
|
|
156
|
+
return (0, fs_1.createReadStream)((0, path_1.join)(__dirname, "../data/response.data.json"));
|
|
157
|
+
}
|
|
158
|
+
testScenario9Get() {
|
|
159
|
+
return "value";
|
|
160
|
+
}
|
|
161
|
+
testScenario9WithDynamicParam(id) {
|
|
162
|
+
return "value" + id;
|
|
163
|
+
}
|
|
164
|
+
testScenario10() {
|
|
165
|
+
const model = new MyModel();
|
|
166
|
+
model.foo = "foo";
|
|
167
|
+
model.ignoreMe = "ignoreMe";
|
|
168
|
+
model.ignoreMe2 = "ignoreMe2";
|
|
169
|
+
model.fooBase = "fooBase";
|
|
170
|
+
model.ignoreMeBase = "ignoreMeBase";
|
|
171
|
+
return model;
|
|
172
|
+
}
|
|
173
|
+
testScenario11() {
|
|
174
|
+
const t = new EmptyModel();
|
|
175
|
+
t.raw = 1;
|
|
176
|
+
t.affected = 1;
|
|
177
|
+
return t;
|
|
178
|
+
}
|
|
179
|
+
testScenario12(res) {
|
|
180
|
+
res.attachment("filename");
|
|
181
|
+
return Buffer.from("Hello");
|
|
182
|
+
}
|
|
183
|
+
async testScenario13(res) {
|
|
184
|
+
const http = (0, superagent_1.agent)();
|
|
185
|
+
const image_res = await http.get("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");
|
|
186
|
+
res.setHeader("Content-Disposition", "inline;filename=googlelogo_color_272x92dp.png;");
|
|
187
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
188
|
+
res.setHeader("Content-Type", "image/png");
|
|
189
|
+
return image_res.body;
|
|
190
|
+
}
|
|
191
|
+
scenario14() {
|
|
192
|
+
return {
|
|
193
|
+
jsonexample: 1
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
testScenario15a() {
|
|
197
|
+
return axios_1.default.get(`https://tsed.io/api.json`, {
|
|
198
|
+
responseType: "json"
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async testScenario15b() {
|
|
202
|
+
return axios_1.default.get(`https://api.tsed.io/rest/github/typed/test`, {
|
|
203
|
+
responseType: "json"
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async testScenario16() {
|
|
207
|
+
const test = new TestNestedEnum();
|
|
208
|
+
const nested = new NestedEnum();
|
|
209
|
+
nested.value = EnumValue.One;
|
|
210
|
+
test.nested = nested;
|
|
211
|
+
return test;
|
|
212
|
+
}
|
|
213
|
+
async testScenario17() {
|
|
214
|
+
const model = new ModelGroup();
|
|
215
|
+
model.id = "id";
|
|
216
|
+
model.groups = "groups";
|
|
217
|
+
return model;
|
|
218
|
+
}
|
|
219
|
+
testScenario18() {
|
|
220
|
+
const data = new TeamsModel();
|
|
221
|
+
const team = {};
|
|
222
|
+
team.name = "name";
|
|
223
|
+
data.teams = [team];
|
|
224
|
+
return data;
|
|
225
|
+
}
|
|
226
|
+
async testScenario19() {
|
|
227
|
+
const model = new AllowedModel();
|
|
228
|
+
model.id = "id";
|
|
229
|
+
model.prop1 = "prop1";
|
|
230
|
+
model.description = "description";
|
|
231
|
+
model.prop2 = "prop2";
|
|
232
|
+
model.sensitiveProp = "sensitiveProp";
|
|
233
|
+
return model;
|
|
234
|
+
}
|
|
235
|
+
async testScenario20() {
|
|
236
|
+
const $ctx = (0, common_1.getContext)();
|
|
237
|
+
return { id: $ctx?.request.query.id };
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
tslib_1.__decorate([
|
|
241
|
+
(0, common_1.Get)("/scenario1/:id"),
|
|
242
|
+
tslib_1.__param(0, (0, common_1.PathParams)("id")),
|
|
243
|
+
tslib_1.__metadata("design:type", Function),
|
|
244
|
+
tslib_1.__metadata("design:paramtypes", [Number]),
|
|
245
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
246
|
+
], TestResponseParamsCtrl.prototype, "testScenario1Get", null);
|
|
247
|
+
tslib_1.__decorate([
|
|
248
|
+
(0, common_1.Post)("/scenario3/:id?"),
|
|
249
|
+
(0, schema_1.Status)(204),
|
|
250
|
+
tslib_1.__param(0, (0, common_1.PathParams)("id")),
|
|
251
|
+
tslib_1.__param(1, (0, common_1.Context)()),
|
|
252
|
+
tslib_1.__metadata("design:type", Function),
|
|
253
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
254
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
255
|
+
], TestResponseParamsCtrl.prototype, "testScenario3EmptyResponse", null);
|
|
256
|
+
tslib_1.__decorate([
|
|
257
|
+
(0, common_1.Get)("/scenario5"),
|
|
258
|
+
tslib_1.__metadata("design:type", Function),
|
|
259
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
260
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
261
|
+
], TestResponseParamsCtrl.prototype, "testScenario5Promise", null);
|
|
262
|
+
tslib_1.__decorate([
|
|
263
|
+
(0, common_1.Get)("/scenario6"),
|
|
264
|
+
tslib_1.__metadata("design:type", Function),
|
|
265
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
266
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
267
|
+
], TestResponseParamsCtrl.prototype, "testScenario6Observable", null);
|
|
268
|
+
tslib_1.__decorate([
|
|
269
|
+
(0, common_1.Get)("/scenario6b"),
|
|
270
|
+
tslib_1.__metadata("design:type", Function),
|
|
271
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
272
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
273
|
+
], TestResponseParamsCtrl.prototype, "testScenario6bObservable", null);
|
|
274
|
+
tslib_1.__decorate([
|
|
275
|
+
(0, common_1.Get)("/scenario7"),
|
|
276
|
+
(0, schema_1.ContentType)("application/json"),
|
|
277
|
+
tslib_1.__metadata("design:type", Function),
|
|
278
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
279
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
280
|
+
], TestResponseParamsCtrl.prototype, "testScenario7Stream", null);
|
|
281
|
+
tslib_1.__decorate([
|
|
282
|
+
(0, common_1.Get)("/scenario7b"),
|
|
283
|
+
(0, schema_1.ContentType)("application/json"),
|
|
284
|
+
tslib_1.__metadata("design:type", Function),
|
|
285
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
286
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
287
|
+
], TestResponseParamsCtrl.prototype, "testScenario7bStream", null);
|
|
288
|
+
tslib_1.__decorate([
|
|
289
|
+
(0, common_1.Get)("/scenario9/static"),
|
|
290
|
+
tslib_1.__metadata("design:type", Function),
|
|
291
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
292
|
+
tslib_1.__metadata("design:returntype", String)
|
|
293
|
+
], TestResponseParamsCtrl.prototype, "testScenario9Get", null);
|
|
294
|
+
tslib_1.__decorate([
|
|
295
|
+
(0, common_1.Get)("/scenario9/:id"),
|
|
296
|
+
tslib_1.__param(0, (0, common_1.PathParams)("id")),
|
|
297
|
+
tslib_1.__metadata("design:type", Function),
|
|
298
|
+
tslib_1.__metadata("design:paramtypes", [Number]),
|
|
299
|
+
tslib_1.__metadata("design:returntype", String)
|
|
300
|
+
], TestResponseParamsCtrl.prototype, "testScenario9WithDynamicParam", null);
|
|
301
|
+
tslib_1.__decorate([
|
|
302
|
+
(0, common_1.Get)("/scenario10"),
|
|
303
|
+
tslib_1.__metadata("design:type", Function),
|
|
304
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
305
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
306
|
+
], TestResponseParamsCtrl.prototype, "testScenario10", null);
|
|
307
|
+
tslib_1.__decorate([
|
|
308
|
+
(0, common_1.Get)("/scenario11"),
|
|
309
|
+
tslib_1.__metadata("design:type", Function),
|
|
310
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
311
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
312
|
+
], TestResponseParamsCtrl.prototype, "testScenario11", null);
|
|
313
|
+
tslib_1.__decorate([
|
|
314
|
+
(0, common_1.Get)("/scenario12"),
|
|
315
|
+
tslib_1.__param(0, (0, common_1.Res)()),
|
|
316
|
+
tslib_1.__metadata("design:type", Function),
|
|
317
|
+
tslib_1.__metadata("design:paramtypes", [common_1.PlatformResponse]),
|
|
318
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
319
|
+
], TestResponseParamsCtrl.prototype, "testScenario12", null);
|
|
320
|
+
tslib_1.__decorate([
|
|
321
|
+
(0, common_1.Get)("/scenario13"),
|
|
322
|
+
tslib_1.__param(0, (0, common_1.Res)()),
|
|
323
|
+
tslib_1.__metadata("design:type", Function),
|
|
324
|
+
tslib_1.__metadata("design:paramtypes", [common_1.PlatformResponse]),
|
|
325
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
326
|
+
], TestResponseParamsCtrl.prototype, "testScenario13", null);
|
|
327
|
+
tslib_1.__decorate([
|
|
328
|
+
(0, common_1.Get)("/scenario14"),
|
|
329
|
+
tslib_1.__metadata("design:type", Function),
|
|
330
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
331
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
332
|
+
], TestResponseParamsCtrl.prototype, "scenario14", null);
|
|
333
|
+
tslib_1.__decorate([
|
|
334
|
+
(0, common_1.Get)("/scenario15a"),
|
|
335
|
+
tslib_1.__metadata("design:type", Function),
|
|
336
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
337
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
338
|
+
], TestResponseParamsCtrl.prototype, "testScenario15a", null);
|
|
339
|
+
tslib_1.__decorate([
|
|
340
|
+
(0, common_1.Get)("/scenario15b"),
|
|
341
|
+
tslib_1.__metadata("design:type", Function),
|
|
342
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
343
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
344
|
+
], TestResponseParamsCtrl.prototype, "testScenario15b", null);
|
|
345
|
+
tslib_1.__decorate([
|
|
346
|
+
(0, common_1.Get)("/scenario16"),
|
|
347
|
+
tslib_1.__metadata("design:type", Function),
|
|
348
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
349
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
350
|
+
], TestResponseParamsCtrl.prototype, "testScenario16", null);
|
|
351
|
+
tslib_1.__decorate([
|
|
352
|
+
(0, common_1.Get)("/scenario17"),
|
|
353
|
+
(0, schema_1.Returns)(201, ModelGroup).Groups("creation"),
|
|
354
|
+
tslib_1.__metadata("design:type", Function),
|
|
355
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
356
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
357
|
+
], TestResponseParamsCtrl.prototype, "testScenario17", null);
|
|
358
|
+
tslib_1.__decorate([
|
|
359
|
+
(0, common_1.Get)("/scenario18"),
|
|
360
|
+
(0, schema_1.Returns)(200, TeamsModel),
|
|
361
|
+
tslib_1.__metadata("design:type", Function),
|
|
362
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
363
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
364
|
+
], TestResponseParamsCtrl.prototype, "testScenario18", null);
|
|
365
|
+
tslib_1.__decorate([
|
|
366
|
+
(0, common_1.Get)("/scenario19"),
|
|
367
|
+
(0, schema_1.Returns)(200, AllowedModel).Groups("!admin").AllowedGroups("summary", "details"),
|
|
368
|
+
tslib_1.__metadata("design:type", Function),
|
|
369
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
370
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
371
|
+
], TestResponseParamsCtrl.prototype, "testScenario19", null);
|
|
372
|
+
tslib_1.__decorate([
|
|
373
|
+
(0, common_1.Get)("/scenario20"),
|
|
374
|
+
tslib_1.__metadata("design:type", Function),
|
|
375
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
376
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
377
|
+
], TestResponseParamsCtrl.prototype, "testScenario20", null);
|
|
378
|
+
TestResponseParamsCtrl = tslib_1.__decorate([
|
|
379
|
+
(0, common_1.Controller)("/response")
|
|
380
|
+
], TestResponseParamsCtrl);
|
|
381
|
+
function testResponse(options) {
|
|
382
|
+
let request;
|
|
383
|
+
beforeAll(common_1.PlatformTest.bootstrap(options.server, {
|
|
384
|
+
...options,
|
|
385
|
+
mount: {
|
|
386
|
+
"/rest": [TestResponseParamsCtrl]
|
|
387
|
+
}
|
|
388
|
+
}));
|
|
389
|
+
beforeAll(() => {
|
|
390
|
+
request = (0, supertest_1.default)(common_1.PlatformTest.callback());
|
|
391
|
+
});
|
|
392
|
+
afterAll(common_1.PlatformTest.reset);
|
|
393
|
+
describe("Scenario1: return the id (classic)", () => {
|
|
394
|
+
describe("GET /rest/response/scenario1/:id", () => {
|
|
395
|
+
it("should return the id + test", async () => {
|
|
396
|
+
const response = await request.get("/rest/response/scenario1/10").expect(200);
|
|
397
|
+
expect(response.text).toEqual("hello-10");
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
describe("Scenario3: when response is empty or created", () => {
|
|
402
|
+
describe("GET /rest/response/scenario3/:id?", () => {
|
|
403
|
+
it("should return nothing with a 204 status", async () => {
|
|
404
|
+
const response = await request.post("/rest/response/scenario3/10").expect(204);
|
|
405
|
+
expect(response.text).toEqual("");
|
|
406
|
+
});
|
|
407
|
+
it("should return a body", async () => {
|
|
408
|
+
const response = await request.post("/rest/response/scenario3").expect(201);
|
|
409
|
+
expect(response.body).toEqual({ id: 1 });
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
describe("Scenario5: when endpoint response from promise", () => {
|
|
414
|
+
describe("GET /rest/response/scenario5", () => {
|
|
415
|
+
it("should return a body", async () => {
|
|
416
|
+
const response = await request.get("/rest/response/scenario5");
|
|
417
|
+
expect(response.body).toEqual({ id: 1 });
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
describe("Scenario6: when endpoint return an observable", () => {
|
|
422
|
+
describe("GET /rest/response/scenario6", () => {
|
|
423
|
+
it("should return a body", async () => {
|
|
424
|
+
const response = await request.get("/rest/response/scenario6");
|
|
425
|
+
expect(response.body).toEqual({ id: 1 });
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
describe("GET /rest/response/scenario6b", () => {
|
|
429
|
+
it("should return a body", async () => {
|
|
430
|
+
const response = await request.get("/rest/response/scenario6b");
|
|
431
|
+
expect(response.body).toEqual({ id: 1 });
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
describe("Scenario7: when endpoint return a stream", () => {
|
|
436
|
+
describe("GET /rest/response/scenario7", () => {
|
|
437
|
+
it("should return a body", async () => {
|
|
438
|
+
const response = await request.get("/rest/response/scenario7");
|
|
439
|
+
expect(response.body).toEqual({ id: "1" });
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
describe("GET /rest/response/scenario7b", () => {
|
|
443
|
+
it("should return a body", async () => {
|
|
444
|
+
const response = await request.get("/rest/response/scenario7b");
|
|
445
|
+
expect(response.body).toEqual({ id: "1" });
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
describe("Scenario9: routes without parameters must be defined first", () => {
|
|
450
|
+
describe("GET /rest/response/scenario9/static", () => {
|
|
451
|
+
it("should return the test", async () => {
|
|
452
|
+
const response = await request.get("/rest/response/scenario9/static").expect(200);
|
|
453
|
+
expect(response.text).toEqual("value");
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
describe("GET /rest/response/scenario9/:dynamic", () => {
|
|
457
|
+
it("should return the test + id", async () => {
|
|
458
|
+
const response = await request.get("/rest/response/scenario9/10").expect(200);
|
|
459
|
+
expect(response.text).toEqual("value10");
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
describe("GET /rest/response/scenario9/:dynamic", () => {
|
|
463
|
+
it("should throw a badRequest when path params isn't set as number", async () => {
|
|
464
|
+
const response = await request.get("/rest/response/scenario9/kkk").expect(400);
|
|
465
|
+
expect(response.body).toEqual({
|
|
466
|
+
errors: [
|
|
467
|
+
{
|
|
468
|
+
data: "kkk",
|
|
469
|
+
dataPath: "",
|
|
470
|
+
instancePath: "",
|
|
471
|
+
keyword: "type",
|
|
472
|
+
message: "must be number",
|
|
473
|
+
params: {
|
|
474
|
+
type: "number"
|
|
475
|
+
},
|
|
476
|
+
schemaPath: "#/type"
|
|
477
|
+
}
|
|
478
|
+
],
|
|
479
|
+
message: 'Bad request on parameter "request.path.id".\nValue must be number. Given value: "kkk"',
|
|
480
|
+
name: "AJV_VALIDATION_ERROR",
|
|
481
|
+
status: 400
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
describe("Scenario10: return a model with ignored props", () => {
|
|
487
|
+
it("should return a body", async () => {
|
|
488
|
+
const response = await request.get("/rest/response/scenario10");
|
|
489
|
+
expect(response.body).toEqual({
|
|
490
|
+
foo: "foo",
|
|
491
|
+
fooBase: "fooBase"
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
describe("Scenario11: return models without props", () => {
|
|
496
|
+
it("should return a body", async () => {
|
|
497
|
+
const response = await request.get("/rest/response/scenario11");
|
|
498
|
+
expect(response.body).toEqual({
|
|
499
|
+
affected: 1,
|
|
500
|
+
raw: 1
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
describe("Scenario12: Return buffer", () => {
|
|
505
|
+
it("should return a body", async () => {
|
|
506
|
+
const response = await request.get("/rest/response/scenario12");
|
|
507
|
+
expect(response.headers["content-disposition"]).toEqual('attachment; filename="filename"');
|
|
508
|
+
expect(response.headers["content-type"]).toContain("application/octet-stream");
|
|
509
|
+
expect(response.headers["content-length"]).toEqual("5");
|
|
510
|
+
expect(response.body.toString()).toEqual("Hello");
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
describe("Scenario13: Return buffer", () => {
|
|
514
|
+
it("should return image", async () => {
|
|
515
|
+
const response = await request.get("/rest/response/scenario13");
|
|
516
|
+
expect(response.headers["content-disposition"]).toEqual("inline;filename=googlelogo_color_272x92dp.png;");
|
|
517
|
+
expect(response.headers["content-type"]).toContain("image/png");
|
|
518
|
+
expect(response.headers["content-length"]).toEqual("5969");
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
describe("Scenario14: Return application/json when Accept is */*", () => {
|
|
522
|
+
it("should return a */* content-type", async () => {
|
|
523
|
+
const response = await request
|
|
524
|
+
.get("/rest/response/scenario14")
|
|
525
|
+
.set("Accept", "*/*")
|
|
526
|
+
.set("Content-Type", "application/json")
|
|
527
|
+
.expect(200);
|
|
528
|
+
expect(response.headers["content-type"]).toEqual("application/json; charset=utf-8");
|
|
529
|
+
expect(response.body).toEqual({
|
|
530
|
+
jsonexample: 1
|
|
531
|
+
});
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
describe("Scenario15: Use axios as proxy", () => {
|
|
535
|
+
it("should return the response (200)", async () => {
|
|
536
|
+
const response = await request.get("/rest/response/scenario15a").expect(200);
|
|
537
|
+
expect(response.headers["content-type"]).toEqual("application/json; charset=utf-8");
|
|
538
|
+
});
|
|
539
|
+
it("should return the response (401)", async () => {
|
|
540
|
+
const response = await request.get("/rest/response/scenario15b").expect(401);
|
|
541
|
+
expect(response.headers["content-type"]).toEqual("application/json; charset=utf-8");
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
describe("Scenario16: Return response with nested enum", () => {
|
|
545
|
+
it("should return the response (200)", async () => {
|
|
546
|
+
const response = await request.get("/rest/response/scenario16").expect(200);
|
|
547
|
+
expect(response.body).toEqual({ nested: { value: "one" } });
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
describe("Scenario17: Return response with groups on 201", () => {
|
|
551
|
+
it("should return the response (200)", async () => {
|
|
552
|
+
const response = await request.get("/rest/response/scenario17").expect(201);
|
|
553
|
+
expect(response.body).toEqual({ id: "id" });
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
describe("Scenario18: Return data with alias", () => {
|
|
557
|
+
it("should return the response (200)", async () => {
|
|
558
|
+
const response = await request.get("/rest/response/scenario18").expect(200);
|
|
559
|
+
expect(response.body).toEqual({
|
|
560
|
+
teams: [
|
|
561
|
+
{
|
|
562
|
+
teamName: "name"
|
|
563
|
+
}
|
|
564
|
+
]
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
describe("Scenario19: includes options", () => {
|
|
569
|
+
it("should return the response (200)", async () => {
|
|
570
|
+
const response = await request.get("/rest/response/scenario19").expect(200);
|
|
571
|
+
expect(response.body).toEqual({
|
|
572
|
+
description: "description",
|
|
573
|
+
id: "id",
|
|
574
|
+
prop1: "prop1",
|
|
575
|
+
prop2: "prop2"
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
it("should return the response (200 + [summary])", async () => {
|
|
579
|
+
const response = await request.get("/rest/response/scenario19?includes=summary").expect(200);
|
|
580
|
+
expect(response.body).toEqual({
|
|
581
|
+
description: "description",
|
|
582
|
+
id: "id",
|
|
583
|
+
prop1: "prop1"
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
it("should return the response (200 + [summary, details])", async () => {
|
|
587
|
+
const response = await request.get("/rest/response/scenario19?includes=summary&includes=details").expect(200);
|
|
588
|
+
expect(response.body).toEqual({
|
|
589
|
+
description: "description",
|
|
590
|
+
id: "id",
|
|
591
|
+
prop2: "prop2",
|
|
592
|
+
prop1: "prop1"
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
it("should return the response (200 + [summary, details, admin])", async () => {
|
|
596
|
+
const response = await request.get("/rest/response/scenario19?includes=summary&includes=details&includes=admin").expect(200);
|
|
597
|
+
expect(response.body).toEqual({
|
|
598
|
+
description: "description",
|
|
599
|
+
id: "id",
|
|
600
|
+
prop2: "prop2",
|
|
601
|
+
prop1: "prop1"
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
it("should return the response (200 + 'summary,details,admin')", async () => {
|
|
605
|
+
const response = await request.get("/rest/response/scenario19?includes=summary,details,admin").expect(200);
|
|
606
|
+
expect(response.body).toEqual({
|
|
607
|
+
description: "description",
|
|
608
|
+
id: "id",
|
|
609
|
+
prop2: "prop2",
|
|
610
|
+
prop1: "prop1"
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
describe("Scenario20: should return query data from Context", () => {
|
|
615
|
+
it("should return the response (200)", async () => {
|
|
616
|
+
const response = await request.get("/rest/response/scenario20?id=id").expect(200);
|
|
617
|
+
expect(response.body).toEqual({ id: "id" });
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
exports.testResponse = testResponse;
|
|
622
|
+
//# sourceMappingURL=testResponse.js.map
|