@tsed/platform-test-sdk 8.12.5 → 8.13.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.
@@ -4,7 +4,7 @@ import { PlatformTest } from "@tsed/platform-http/testing";
4
4
  import { Context, PathParams } from "@tsed/platform-params";
5
5
  import { Get, Pattern, Post } from "@tsed/schema";
6
6
  import SuperTest from "supertest";
7
- import { afterAll, beforeAll, expect, it } from "vitest";
7
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
8
8
  let TestPathParamsCtrl = class TestPathParamsCtrl {
9
9
  testScenario1(scope) {
10
10
  // Here scope will be {0: 'a', 1: 'b', 2: 'c'} instead of 'abc' in version 5.47.0
@@ -32,6 +32,19 @@ let TestPathParamsCtrl = class TestPathParamsCtrl {
32
32
  testScenario6(id) {
33
33
  return { id };
34
34
  }
35
+ // test path syntaxes
36
+ testSyntax1(wildcard, ctx) {
37
+ return { wildcard };
38
+ }
39
+ testSyntax2(wildcard, ctx) {
40
+ return { wildcard };
41
+ }
42
+ testSyntax3(wildcard, ctx) {
43
+ return { wildcard };
44
+ }
45
+ testSyntax4(named, ctx) {
46
+ return { named };
47
+ }
35
48
  };
36
49
  __decorate([
37
50
  Get("/scenario-1/:scope/:scopeId"),
@@ -78,6 +91,38 @@ __decorate([
78
91
  __metadata("design:paramtypes", [Number]),
79
92
  __metadata("design:returntype", void 0)
80
93
  ], TestPathParamsCtrl.prototype, "testScenario6", null);
94
+ __decorate([
95
+ Get("/syntax-1/*"),
96
+ __param(0, PathParams("*")),
97
+ __param(1, Context()),
98
+ __metadata("design:type", Function),
99
+ __metadata("design:paramtypes", [String, Function]),
100
+ __metadata("design:returntype", void 0)
101
+ ], TestPathParamsCtrl.prototype, "testSyntax1", null);
102
+ __decorate([
103
+ Get("/syntax-2/(.*)"),
104
+ __param(0, PathParams("*")),
105
+ __param(1, Context()),
106
+ __metadata("design:type", Function),
107
+ __metadata("design:paramtypes", [String, Function]),
108
+ __metadata("design:returntype", void 0)
109
+ ], TestPathParamsCtrl.prototype, "testSyntax2", null);
110
+ __decorate([
111
+ Get("/syntax-3/:named*"),
112
+ __param(0, PathParams("named")),
113
+ __param(1, Context()),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", [String, Function]),
116
+ __metadata("design:returntype", void 0)
117
+ ], TestPathParamsCtrl.prototype, "testSyntax3", null);
118
+ __decorate([
119
+ Get("/syntax-4/:named?"),
120
+ __param(0, PathParams("named")),
121
+ __param(1, Context()),
122
+ __metadata("design:type", Function),
123
+ __metadata("design:paramtypes", [String, Function]),
124
+ __metadata("design:returntype", void 0)
125
+ ], TestPathParamsCtrl.prototype, "testSyntax4", null);
81
126
  TestPathParamsCtrl = __decorate([
82
127
  Controller("/path-params")
83
128
  ], TestPathParamsCtrl);
@@ -85,6 +130,9 @@ export function testPathParams(options) {
85
130
  let request;
86
131
  beforeAll(PlatformTest.bootstrap(options.server, {
87
132
  ...options,
133
+ // logger: {
134
+ // level: "info"
135
+ // },
88
136
  mount: {
89
137
  "/rest": [TestPathParamsCtrl]
90
138
  }
@@ -138,4 +186,22 @@ export function testPathParams(options) {
138
186
  const response = await request.get("/rest/path-params/scenario-6/1").expect(200);
139
187
  expect(response.body).toEqual({ id: 1 });
140
188
  });
189
+ describe("path syntaxes", () => {
190
+ it("Syntax 1: GET /rest/path-params/syntax-1/*", async () => {
191
+ const response = await request.get("/rest/path-params/syntax-1/abc/def").expect(200);
192
+ expect(response.body).toEqual({ wildcard: "abc/def" });
193
+ });
194
+ it("Syntax 2: GET /rest/path-params/syntax-2/(.*)", async () => {
195
+ const response = await request.get("/rest/path-params/syntax-2/abc/def").expect(200);
196
+ expect(response.body).toEqual({ wildcard: "abc/def" });
197
+ });
198
+ it("Syntax 3: GET /rest/path-params/syntax-3/:named*", async () => {
199
+ const response = await request.get("/rest/path-params/syntax-3/abc/def").expect(200);
200
+ expect(response.body).toEqual({ wildcard: "abc/def" });
201
+ });
202
+ it("Syntax 4: GET /rest/path-params/syntax-4/:named?", async () => {
203
+ const response = await request.get("/rest/path-params/syntax-4/named").expect(200);
204
+ expect(response.body).toEqual({ named: "named" });
205
+ });
206
+ });
141
207
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/platform-test-sdk",
3
3
  "description": "Package to test platform adapter integration with Ts.ED",
4
4
  "type": "module",
5
- "version": "8.12.5",
5
+ "version": "8.13.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -28,25 +28,25 @@
28
28
  "Adapter"
29
29
  ],
30
30
  "dependencies": {
31
- "@tsed/ajv": "8.12.5",
32
- "@tsed/core": "8.12.5",
33
- "@tsed/di": "8.12.5",
34
- "@tsed/json-mapper": "8.12.5",
31
+ "@tsed/ajv": "8.13.0",
32
+ "@tsed/core": "8.13.0",
33
+ "@tsed/di": "8.13.0",
34
+ "@tsed/json-mapper": "8.13.0",
35
35
  "@tsed/logger": "7.0.1",
36
- "@tsed/platform-cache": "8.12.5",
37
- "@tsed/platform-http": "8.12.5",
38
- "@tsed/platform-params": "8.12.5",
39
- "@tsed/platform-router": "8.12.5",
40
- "@tsed/platform-views": "8.12.5",
41
- "@tsed/schema": "8.12.5",
42
- "@tsed/swagger": "8.12.5",
36
+ "@tsed/platform-cache": "8.13.0",
37
+ "@tsed/platform-http": "8.13.0",
38
+ "@tsed/platform-params": "8.13.0",
39
+ "@tsed/platform-router": "8.13.0",
40
+ "@tsed/platform-views": "8.13.0",
41
+ "@tsed/schema": "8.13.0",
42
+ "@tsed/swagger": "8.13.0",
43
43
  "ajv": "^8.17.1",
44
44
  "axios": "1.7.7",
45
45
  "read-pkg-up": "7.0.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@tsed/barrels": "8.12.5",
49
- "@tsed/typescript": "8.12.5",
48
+ "@tsed/barrels": "8.13.0",
49
+ "@tsed/typescript": "8.13.0",
50
50
  "eslint": "9.12.0",
51
51
  "typescript": "5.4.5"
52
52
  },