@tsed/platform-test-sdk 7.79.4 → 7.80.1
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/tests/testHeaders.js +8 -24
- package/lib/cjs/tests/testHeaders.js.map +1 -1
- package/lib/cjs/tests/testInheritanceController.js +2 -1
- package/lib/cjs/tests/testInheritanceController.js.map +1 -1
- package/lib/cjs/tests/testMulter.js +5 -3
- package/lib/cjs/tests/testMulter.js.map +1 -1
- package/lib/cjs/tests/testRouting.js +4 -2
- package/lib/cjs/tests/testRouting.js.map +1 -1
- package/lib/cjs/tests/testStream.js +1 -1
- package/lib/esm/tests/testHeaders.js +8 -24
- package/lib/esm/tests/testHeaders.js.map +1 -1
- package/lib/esm/tests/testInheritanceController.js +2 -1
- package/lib/esm/tests/testInheritanceController.js.map +1 -1
- package/lib/esm/tests/testMulter.js +6 -4
- package/lib/esm/tests/testMulter.js.map +1 -1
- package/lib/esm/tests/testRouting.js +4 -2
- package/lib/esm/tests/testRouting.js.map +1 -1
- package/lib/esm/tests/testStream.js +1 -1
- package/lib/types-esm/components/PlatformTestSdk.d.ts +9 -0
- package/lib/types-esm/errors/CustomBadRequest.d.ts +8 -0
- package/lib/types-esm/errors/CustomInternalError.d.ts +8 -0
- package/lib/types-esm/interfaces/PlatformTestingSdkOpts.d.ts +8 -0
- package/lib/types-esm/modules/feature/FeatureModule.d.ts +2 -0
- package/lib/types-esm/modules/feature/controllers/FeatureController.d.ts +3 -0
- package/lib/types-esm/tests/exports.d.ts +2 -0
- package/lib/types-esm/tests/testAcceptMime.d.ts +2 -0
- package/lib/types-esm/tests/testAuth.d.ts +8 -0
- package/lib/types-esm/tests/testBodyParams.d.ts +3 -0
- package/lib/types-esm/tests/testCache.d.ts +2 -0
- package/lib/types-esm/tests/testChildrenControllers.d.ts +2 -0
- package/lib/types-esm/tests/testCookies.d.ts +11 -0
- package/lib/types-esm/tests/testCustom404.d.ts +2 -0
- package/lib/types-esm/tests/testDeepQueryParams.d.ts +3 -0
- package/lib/types-esm/tests/testErrors.d.ts +19 -0
- package/lib/types-esm/tests/testHandlers.d.ts +12 -0
- package/lib/types-esm/tests/testHeaderParams.d.ts +16 -0
- package/lib/types-esm/tests/testHeaders.d.ts +8 -0
- package/lib/types-esm/tests/testInheritanceController.d.ts +42 -0
- package/lib/types-esm/tests/testLocals.d.ts +2 -0
- package/lib/types-esm/tests/testLocation.d.ts +2 -0
- package/lib/types-esm/tests/testMiddlewares.d.ts +8 -0
- package/lib/types-esm/tests/testModule.d.ts +2 -0
- package/lib/types-esm/tests/testMulter.d.ts +21 -0
- package/lib/types-esm/tests/testPathParams.d.ts +2 -0
- package/lib/types-esm/tests/testQueryParams.d.ts +6 -0
- package/lib/types-esm/tests/testRedirect.d.ts +2 -0
- package/lib/types-esm/tests/testResponse.d.ts +16 -0
- package/lib/types-esm/tests/testResponseFilter.d.ts +2 -0
- package/lib/types-esm/tests/testRouting.d.ts +7 -0
- package/lib/types-esm/tests/testScopeRequest.d.ts +12 -0
- package/lib/types-esm/tests/testSession.d.ts +16 -0
- package/lib/types-esm/tests/testStatics.d.ts +2 -0
- package/lib/types-esm/tests/testStream.d.ts +2 -0
- package/lib/types-esm/tests/testView.d.ts +2 -0
- package/package.json +22 -20
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/lib/tsconfig.esm.tsbuildinfo +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/components/PlatformTestSdk.ts +0 -29
- package/src/data/file.txt +0 -1
- package/src/data/response.data.json +0 -3
- package/src/data/swagger.json +0 -32
- package/src/errors/CustomBadRequest.ts +0 -16
- package/src/errors/CustomInternalError.ts +0 -16
- package/src/interfaces/PlatformTestingSdkOpts.ts +0 -10
- package/src/modules/feature/FeatureModule.ts +0 -9
- package/src/modules/feature/controllers/FeatureController.ts +0 -11
- package/src/tests/exports.ts +0 -71
- package/src/tests/testAcceptMime.ts +0 -95
- package/src/tests/testAuth.ts +0 -339
- package/src/tests/testBodyParams.ts +0 -483
- package/src/tests/testCache.ts +0 -279
- package/src/tests/testChildrenControllers.ts +0 -55
- package/src/tests/testCookies.ts +0 -36
- package/src/tests/testCustom404.ts +0 -33
- package/src/tests/testDeepQueryParams.ts +0 -120
- package/src/tests/testErrors.ts +0 -226
- package/src/tests/testHandlers.ts +0 -90
- package/src/tests/testHeaderParams.ts +0 -152
- package/src/tests/testHeaders.ts +0 -91
- package/src/tests/testInheritanceController.ts +0 -200
- package/src/tests/testLocals.ts +0 -46
- package/src/tests/testLocation.ts +0 -37
- package/src/tests/testMiddlewares.ts +0 -159
- package/src/tests/testModule.ts +0 -46
- package/src/tests/testMulter.ts +0 -151
- package/src/tests/testPathParams.ts +0 -123
- package/src/tests/testQueryParams.ts +0 -233
- package/src/tests/testRedirect.ts +0 -124
- package/src/tests/testResponse.ts +0 -528
- package/src/tests/testResponseFilter.ts +0 -101
- package/src/tests/testRouting.ts +0 -65
- package/src/tests/testScopeRequest.ts +0 -111
- package/src/tests/testSession.ts +0 -103
- package/src/tests/testStatics.ts +0 -61
- package/src/tests/testStream.ts +0 -59
- package/src/tests/testView.ts +0 -68
- package/tsconfig.esm.json +0 -63
- package/tsconfig.json +0 -63
- /package/{src/index.ts → lib/types-esm/index.d.ts} +0 -0
- /package/{src/interfaces/index.ts → lib/types-esm/interfaces/index.d.ts} +0 -0
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {Controller, Get, PathParams, PlatformTest, ProviderScope, Scope, Service} from "@tsed/common";
|
|
2
|
-
import SuperTest from "supertest";
|
|
3
|
-
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
4
|
-
|
|
5
|
-
@Service()
|
|
6
|
-
@Scope(ProviderScope.REQUEST)
|
|
7
|
-
export class ScopeRequestService {
|
|
8
|
-
user: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@Controller("/scopes-request")
|
|
12
|
-
@Scope(ProviderScope.REQUEST)
|
|
13
|
-
export class ScopeRequestCtrl {
|
|
14
|
-
userId: string | null;
|
|
15
|
-
|
|
16
|
-
constructor(public scopeRequestService: ScopeRequestService) {}
|
|
17
|
-
|
|
18
|
-
$onDestroy() {
|
|
19
|
-
this.userId = null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Get("/:id")
|
|
23
|
-
testPerRequest(@PathParams("id") userId: string): Promise<any> {
|
|
24
|
-
this.scopeRequestService.user = userId;
|
|
25
|
-
this.userId = userId;
|
|
26
|
-
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
if (userId === "0") {
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
resolve({userId, idSrv: this.scopeRequestService.user, idCtrl: this.userId});
|
|
31
|
-
}, 500);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (userId === "1") {
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
resolve({userId, idSrv: this.scopeRequestService.user, idCtrl: this.userId});
|
|
37
|
-
}, 300);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (userId === "2") {
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
resolve({userId, idSrv: this.scopeRequestService.user, idCtrl: this.userId});
|
|
43
|
-
}, 150);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function testScopeRequest(options: PlatformTestingSdkOpts) {
|
|
50
|
-
let request: SuperTest.Agent;
|
|
51
|
-
|
|
52
|
-
beforeAll(
|
|
53
|
-
PlatformTest.bootstrap(options.server, {
|
|
54
|
-
...options,
|
|
55
|
-
mount: {
|
|
56
|
-
"/rest": [ScopeRequestCtrl]
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
);
|
|
60
|
-
beforeAll(() => {
|
|
61
|
-
request = SuperTest(PlatformTest.callback());
|
|
62
|
-
});
|
|
63
|
-
afterAll(PlatformTest.reset);
|
|
64
|
-
|
|
65
|
-
describe("GET /rest/scopes-request/:id", () => {
|
|
66
|
-
const send = (id: string) =>
|
|
67
|
-
new Promise((resolve, reject) => {
|
|
68
|
-
request
|
|
69
|
-
.get(`/rest/scopes-request/${id}`)
|
|
70
|
-
.expect(200)
|
|
71
|
-
.end((err: any, response: any) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
reject(err);
|
|
74
|
-
} else {
|
|
75
|
-
resolve({id, ...JSON.parse(response.text)});
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should respond with the right userId per request", () => {
|
|
81
|
-
const promises = [];
|
|
82
|
-
|
|
83
|
-
promises.push(send("0"));
|
|
84
|
-
promises.push(send("1"));
|
|
85
|
-
promises.push(send("2"));
|
|
86
|
-
|
|
87
|
-
return Promise.all(promises).then((responses) => {
|
|
88
|
-
expect(responses).toEqual([
|
|
89
|
-
{
|
|
90
|
-
id: "0",
|
|
91
|
-
idCtrl: "0",
|
|
92
|
-
idSrv: "0",
|
|
93
|
-
userId: "0"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: "1",
|
|
97
|
-
idCtrl: "1",
|
|
98
|
-
idSrv: "1",
|
|
99
|
-
userId: "1"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
id: "2",
|
|
103
|
-
idCtrl: "2",
|
|
104
|
-
idSrv: "2",
|
|
105
|
-
userId: "2"
|
|
106
|
-
}
|
|
107
|
-
]);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
package/src/tests/testSession.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {BodyParams, Constant, Controller, Get, PlatformTest, Post, Req, Session} from "@tsed/common";
|
|
2
|
-
import {NotFound} from "@tsed/exceptions";
|
|
3
|
-
import {Allow, Email, Ignore, MinLength, Property, Required, Returns} from "@tsed/schema";
|
|
4
|
-
import SuperTest from "supertest";
|
|
5
|
-
import {promisify} from "util";
|
|
6
|
-
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
7
|
-
|
|
8
|
-
export class UserCreation {
|
|
9
|
-
@Property()
|
|
10
|
-
name: string;
|
|
11
|
-
|
|
12
|
-
@Required()
|
|
13
|
-
@Email()
|
|
14
|
-
@Allow(null)
|
|
15
|
-
email: string;
|
|
16
|
-
|
|
17
|
-
@Required()
|
|
18
|
-
@MinLength(6)
|
|
19
|
-
@Allow(null)
|
|
20
|
-
password: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class User extends UserCreation {
|
|
24
|
-
@Ignore()
|
|
25
|
-
declare password: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@Controller("/session")
|
|
29
|
-
export class SessionCtrl {
|
|
30
|
-
@Constant("PLATFORM_NAME")
|
|
31
|
-
platformName: string;
|
|
32
|
-
|
|
33
|
-
@Post("/connect")
|
|
34
|
-
connect(@Session() session: any, @BodyParams() user: UserCreation) {
|
|
35
|
-
session.user = user;
|
|
36
|
-
|
|
37
|
-
return Promise.resolve(user);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Get("/userinfo")
|
|
41
|
-
@Returns(200, User)
|
|
42
|
-
userInfo(@Session("user") user: User): Promise<User> {
|
|
43
|
-
if (!user) {
|
|
44
|
-
return Promise.reject(new NotFound("User not found"));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Promise.resolve(user);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Get("/logout")
|
|
51
|
-
@Returns(204)
|
|
52
|
-
logout(@Req() req: any) {
|
|
53
|
-
switch (this.platformName) {
|
|
54
|
-
case "koa":
|
|
55
|
-
return Promise.resolve((req.ctx.session = null));
|
|
56
|
-
case "express":
|
|
57
|
-
delete req.session.user;
|
|
58
|
-
|
|
59
|
-
return promisify(req.session.destroy.bind(req.session))();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return Promise.resolve();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function testSession(options: PlatformTestingSdkOpts) {
|
|
67
|
-
let request: SuperTest.Agent;
|
|
68
|
-
beforeAll(
|
|
69
|
-
PlatformTest.bootstrap(options.server, {
|
|
70
|
-
...options,
|
|
71
|
-
mount: {
|
|
72
|
-
"/rest": [SessionCtrl]
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
beforeAll(() => {
|
|
77
|
-
request = SuperTest.agent(PlatformTest.callback());
|
|
78
|
-
});
|
|
79
|
-
afterAll(PlatformTest.reset);
|
|
80
|
-
|
|
81
|
-
describe("Scenario1: POST /rest/session/connected", () => {
|
|
82
|
-
it("should keep connected user in session and destroy session", async () => {
|
|
83
|
-
await request.get("/rest/session/userinfo").expect(404);
|
|
84
|
-
|
|
85
|
-
await request.post("/rest/session/connect").send({
|
|
86
|
-
name: "name",
|
|
87
|
-
email: "test@test.fr",
|
|
88
|
-
password: "password1234"
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
const response = await request.get("/rest/session/userinfo").expect(200);
|
|
93
|
-
|
|
94
|
-
expect(response.body).toEqual({
|
|
95
|
-
email: "test@test.fr",
|
|
96
|
-
name: "name"
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
await request.get("/rest/session/logout").expect(204);
|
|
100
|
-
await request.get("/rest/session/userinfo").expect(404);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
package/src/tests/testStatics.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {Controller, PlatformTest} from "@tsed/common";
|
|
2
|
-
import {getValue} from "@tsed/core";
|
|
3
|
-
import {Configuration} from "@tsed/di";
|
|
4
|
-
import {PlatformRouter} from "@tsed/platform-router";
|
|
5
|
-
import {readFileSync} from "fs";
|
|
6
|
-
import SuperTest from "supertest";
|
|
7
|
-
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
8
|
-
|
|
9
|
-
@Controller("/statics")
|
|
10
|
-
class CustomStaticsCtrl {
|
|
11
|
-
constructor(router: PlatformRouter, @Configuration() config: Configuration) {
|
|
12
|
-
router.statics("/", {
|
|
13
|
-
root: String(getValue(config, "statics./"))
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function testStatics(options: PlatformTestingSdkOpts) {
|
|
19
|
-
let request: SuperTest.Agent;
|
|
20
|
-
beforeEach(
|
|
21
|
-
PlatformTest.bootstrap(options.server, {
|
|
22
|
-
...options,
|
|
23
|
-
mount: {
|
|
24
|
-
"/rest": [CustomStaticsCtrl]
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
request = SuperTest(PlatformTest.callback());
|
|
30
|
-
});
|
|
31
|
-
afterEach(PlatformTest.reset);
|
|
32
|
-
|
|
33
|
-
it("should return index HTML (1)", async () => {
|
|
34
|
-
const response = await request.get("/").expect(200);
|
|
35
|
-
|
|
36
|
-
expect(response.text).toEqual(readFileSync(`${options.rootDir}/public/index.html`, {encoding: "utf8"}));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should return index HTML (2)", async () => {
|
|
40
|
-
const response = await request.get("/index.html").expect(200);
|
|
41
|
-
|
|
42
|
-
expect(response.text).toEqual(readFileSync(`${options.rootDir}/public/index.html`, {encoding: "utf8"}));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should return index HTML (3)", async () => {
|
|
46
|
-
const response = await request.get("/rest/statics/index.html").expect(200);
|
|
47
|
-
|
|
48
|
-
expect(response.text).toEqual(readFileSync(`${options.rootDir}/public/index.html`, {encoding: "utf8"}));
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should return 404", async () => {
|
|
52
|
-
const response = await request.get("/index-te.html").expect(404);
|
|
53
|
-
|
|
54
|
-
expect(response.body).toEqual({
|
|
55
|
-
errors: [],
|
|
56
|
-
message: 'Resource "/index-te.html" not found',
|
|
57
|
-
name: "NOT_FOUND",
|
|
58
|
-
status: 404
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
package/src/tests/testStream.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {Controller, Get, PlatformTest} from "@tsed/common";
|
|
2
|
-
import {ContentType} from "@tsed/schema";
|
|
3
|
-
import {createReadStream} from "fs";
|
|
4
|
-
import {join} from "path";
|
|
5
|
-
import SuperTest from "supertest";
|
|
6
|
-
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
7
|
-
|
|
8
|
-
const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
|
|
9
|
-
|
|
10
|
-
@Controller("/stream")
|
|
11
|
-
class TestStreamCtrl {
|
|
12
|
-
@Get("/scenario1")
|
|
13
|
-
@ContentType("application/json")
|
|
14
|
-
testScenario1() {
|
|
15
|
-
return createReadStream(join(rootDir, "../data/response.data.json"), "utf-8");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Get("/scenario1b")
|
|
19
|
-
@ContentType("application/json")
|
|
20
|
-
testScenario2() {
|
|
21
|
-
return Promise.resolve(createReadStream(join(rootDir, "../data/response.data.json"), "utf-8"));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function testStream(options: PlatformTestingSdkOpts) {
|
|
26
|
-
let request: SuperTest.Agent;
|
|
27
|
-
|
|
28
|
-
beforeAll(
|
|
29
|
-
PlatformTest.bootstrap(options.server, {
|
|
30
|
-
...options,
|
|
31
|
-
mount: {
|
|
32
|
-
"/rest": [TestStreamCtrl]
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
beforeAll(() => {
|
|
37
|
-
request = SuperTest(PlatformTest.callback());
|
|
38
|
-
});
|
|
39
|
-
afterAll(PlatformTest.reset);
|
|
40
|
-
|
|
41
|
-
describe("Scenario1: when endpoint return a stream", () => {
|
|
42
|
-
describe("GET /rest/stream/scenario1", () => {
|
|
43
|
-
it("should return a body", async () => {
|
|
44
|
-
const response = await request.get("/rest/stream/scenario1");
|
|
45
|
-
|
|
46
|
-
expect(response.headers["content-type"]).toContain("application/json");
|
|
47
|
-
expect(response.body).toEqual({id: "1"});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("GET /rest/stream/scenario1b", () => {
|
|
52
|
-
it("should return a body", async () => {
|
|
53
|
-
const response = await request.get("/rest/stream/scenario1b");
|
|
54
|
-
|
|
55
|
-
expect(response.body).toEqual({id: "1"});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
package/src/tests/testView.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {Controller, Get, Locals, Middleware, PlatformTest, UseBefore} from "@tsed/common";
|
|
2
|
-
import {EOL} from "os";
|
|
3
|
-
import SuperTest from "supertest";
|
|
4
|
-
import {View} from "@tsed/platform-views";
|
|
5
|
-
import {PlatformTestingSdkOpts} from "../interfaces/index.js";
|
|
6
|
-
|
|
7
|
-
@Middleware()
|
|
8
|
-
class LocalsMiddleware {
|
|
9
|
-
use(@Locals() locals: any) {
|
|
10
|
-
locals.localID = "local-10909";
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@Controller("/views")
|
|
15
|
-
class ViewCtrl {
|
|
16
|
-
@Get("/scenario-1")
|
|
17
|
-
@UseBefore(LocalsMiddleware)
|
|
18
|
-
@View("view.ejs", {opts: "opts"})
|
|
19
|
-
testScenario1() {
|
|
20
|
-
return {
|
|
21
|
-
world: "world"
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Get("/scenario-2")
|
|
26
|
-
@View("view", {opts: "opts"}) // missing extension
|
|
27
|
-
testScenario2() {
|
|
28
|
-
return {
|
|
29
|
-
world: "world"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function testView(options: PlatformTestingSdkOpts) {
|
|
35
|
-
let request: SuperTest.Agent;
|
|
36
|
-
|
|
37
|
-
beforeAll(
|
|
38
|
-
PlatformTest.bootstrap(options.server, {
|
|
39
|
-
...options,
|
|
40
|
-
mount: {
|
|
41
|
-
"/rest": [ViewCtrl]
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
beforeAll(() => {
|
|
46
|
-
request = SuperTest(PlatformTest.callback());
|
|
47
|
-
});
|
|
48
|
-
afterAll(PlatformTest.reset);
|
|
49
|
-
|
|
50
|
-
describe("Scenario1: GET /rest/views/scenario-1", () => {
|
|
51
|
-
it("should render a view", async () => {
|
|
52
|
-
const response = await request.get("/rest/views/scenario-1").expect(200);
|
|
53
|
-
|
|
54
|
-
expect(response.headers["content-type"]).toEqual("text/html; charset=utf-8");
|
|
55
|
-
expect(response.text).toEqual(`<p>Hello world with opts and ID local-10909</p>${EOL}`);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("Scenario2: GET /rest/views/scenario-2", () => {
|
|
60
|
-
it("should throw an error when extension is not defined", async () => {
|
|
61
|
-
const response = await request.get("/rest/views/scenario-2").expect(500);
|
|
62
|
-
|
|
63
|
-
expect(response.body.name).toEqual("TEMPLATE_RENDER_ERROR");
|
|
64
|
-
expect(response.body.message).toContain("Template rendering error: ViewCtrl.testScenario2()");
|
|
65
|
-
expect(response.body.status).toEqual(500);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
package/tsconfig.esm.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsed/typescript/tsconfig.node.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"module": "ES2020",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"outDir": "./lib/esm",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./lib/types",
|
|
10
|
-
"composite": true,
|
|
11
|
-
"noEmit": false
|
|
12
|
-
},
|
|
13
|
-
"include": ["src", "src/**/*.json"],
|
|
14
|
-
"exclude": [
|
|
15
|
-
"node_modules",
|
|
16
|
-
"test",
|
|
17
|
-
"lib",
|
|
18
|
-
"benchmark",
|
|
19
|
-
"coverage",
|
|
20
|
-
"spec",
|
|
21
|
-
"**/*.benchmark.ts",
|
|
22
|
-
"**/*.spec.ts",
|
|
23
|
-
"keys",
|
|
24
|
-
"jest.config.js",
|
|
25
|
-
"**/__mock__/**",
|
|
26
|
-
"webpack.config.js"
|
|
27
|
-
],
|
|
28
|
-
"references": [
|
|
29
|
-
{
|
|
30
|
-
"path": "../../specs/ajv"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../common"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../core"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../di"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../specs/json-mapper"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"path": "../platform-cache"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"path": "../platform-params"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"path": "../platform-router"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"path": "../platform-views"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"path": "../../specs/schema"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"path": "../../specs/swagger"
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsed/typescript/tsconfig.node.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"outDir": "./lib/cjs",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./lib/types",
|
|
10
|
-
"composite": true,
|
|
11
|
-
"noEmit": false
|
|
12
|
-
},
|
|
13
|
-
"include": ["src", "src/**/*.json"],
|
|
14
|
-
"exclude": [
|
|
15
|
-
"node_modules",
|
|
16
|
-
"test",
|
|
17
|
-
"lib",
|
|
18
|
-
"benchmark",
|
|
19
|
-
"coverage",
|
|
20
|
-
"spec",
|
|
21
|
-
"**/*.benchmark.ts",
|
|
22
|
-
"**/*.spec.ts",
|
|
23
|
-
"keys",
|
|
24
|
-
"jest.config.js",
|
|
25
|
-
"**/__mock__/**",
|
|
26
|
-
"webpack.config.js"
|
|
27
|
-
],
|
|
28
|
-
"references": [
|
|
29
|
-
{
|
|
30
|
-
"path": "../../specs/ajv"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../common"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../core"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../di"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../specs/json-mapper"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"path": "../platform-cache"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"path": "../platform-params"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"path": "../platform-router"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"path": "../platform-views"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"path": "../../specs/schema"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"path": "../../specs/swagger"
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
File without changes
|
|
File without changes
|