@fluojs/testing 1.0.0-beta.2 → 1.0.0-beta.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.
- package/README.ko.md +66 -17
- package/README.md +64 -15
- package/dist/app.d.ts +2 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +1 -1
- package/dist/babel-decorators-plugin.d.ts +2 -2
- package/dist/babel-decorators-plugin.d.ts.map +1 -1
- package/dist/babel-decorators-plugin.js +26 -12
- package/dist/conformance/fetch-style-websocket-conformance.d.ts +12 -0
- package/dist/conformance/fetch-style-websocket-conformance.d.ts.map +1 -1
- package/dist/conformance/fetch-style-websocket-conformance.js +14 -0
- package/dist/conformance/platform-conformance.d.ts +21 -0
- package/dist/conformance/platform-conformance.d.ts.map +1 -1
- package/dist/conformance/platform-conformance.js +27 -0
- package/dist/mock.d.ts +17 -0
- package/dist/mock.d.ts.map +1 -1
- package/dist/mock.js +19 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +106 -11
- package/dist/portability/http-adapter-portability.d.ts +9 -0
- package/dist/portability/http-adapter-portability.d.ts.map +1 -1
- package/dist/portability/http-adapter-portability.js +102 -42
- package/dist/portability/web-runtime-adapter-portability.d.ts +13 -0
- package/dist/portability/web-runtime-adapter-portability.d.ts.map +1 -1
- package/dist/portability/web-runtime-adapter-portability.js +76 -20
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -7,6 +7,11 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
7
7
|
import { Controller, Get, Post, SseResponse } from '@fluojs/http';
|
|
8
8
|
// @ts-ignore Worktree-local LSP does not resolve workspace package aliases.
|
|
9
9
|
import { defineModule } from '@fluojs/runtime';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Describes the web runtime http adapter portability harness options contract.
|
|
13
|
+
*/
|
|
14
|
+
|
|
10
15
|
function decodeUtf8(input) {
|
|
11
16
|
return new TextDecoder().decode(input ?? new Uint8Array());
|
|
12
17
|
}
|
|
@@ -15,28 +20,72 @@ async function closeSilently(app) {
|
|
|
15
20
|
await app.close();
|
|
16
21
|
} catch {}
|
|
17
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the web runtime http adapter portability harness.
|
|
26
|
+
*/
|
|
18
27
|
export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
19
28
|
constructor(options) {
|
|
20
29
|
this.options = options;
|
|
21
30
|
}
|
|
22
|
-
async
|
|
31
|
+
async assertPreservesQueryArraysAndDecoding() {
|
|
23
32
|
let _initProto, _initClass;
|
|
33
|
+
let _QueryController;
|
|
34
|
+
class QueryController {
|
|
35
|
+
static {
|
|
36
|
+
({
|
|
37
|
+
e: [_initProto],
|
|
38
|
+
c: [_QueryController, _initClass]
|
|
39
|
+
} = _applyDecs(this, [Controller('/query')], [[Get('/'), 2, "readQuery"]]));
|
|
40
|
+
}
|
|
41
|
+
constructor() {
|
|
42
|
+
_initProto(this);
|
|
43
|
+
}
|
|
44
|
+
readQuery(_input, context) {
|
|
45
|
+
return context.request.query;
|
|
46
|
+
}
|
|
47
|
+
static {
|
|
48
|
+
_initClass();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class AppModule {}
|
|
52
|
+
defineModule(AppModule, {
|
|
53
|
+
controllers: [_QueryController]
|
|
54
|
+
});
|
|
55
|
+
const app = await this.options.bootstrap(AppModule, {
|
|
56
|
+
cors: false
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
const response = await app.dispatch(new Request('https://runtime.test/query?tag=one&tag=two&encoded=hello+world&flag&bad=%E0%A4%A'));
|
|
60
|
+
if (response.status !== 200) {
|
|
61
|
+
throw new Error(`${this.options.name} adapter changed query response status semantics.`);
|
|
62
|
+
}
|
|
63
|
+
const body = await response.json();
|
|
64
|
+
if (typeof body !== 'object' || body === null || body.bad !== '�%A' || body.encoded !== 'hello world' || !Array.isArray(body.tag) || JSON.stringify(body.tag) !== JSON.stringify(['one', 'two'])) {
|
|
65
|
+
throw new Error(`${this.options.name} adapter changed query decoding semantics.`);
|
|
66
|
+
}
|
|
67
|
+
} finally {
|
|
68
|
+
await closeSilently(app);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async assertPreservesMalformedCookieValues() {
|
|
72
|
+
let _initProto2, _initClass2;
|
|
24
73
|
let _CookieController;
|
|
25
74
|
class CookieController {
|
|
26
75
|
static {
|
|
27
76
|
({
|
|
28
|
-
e: [
|
|
29
|
-
c: [_CookieController,
|
|
77
|
+
e: [_initProto2],
|
|
78
|
+
c: [_CookieController, _initClass2]
|
|
30
79
|
} = _applyDecs(this, [Controller('/cookies')], [[Get('/'), 2, "readCookies"]]));
|
|
31
80
|
}
|
|
32
81
|
constructor() {
|
|
33
|
-
|
|
82
|
+
_initProto2(this);
|
|
34
83
|
}
|
|
35
84
|
readCookies(_input, context) {
|
|
36
85
|
return context.request.cookies;
|
|
37
86
|
}
|
|
38
87
|
static {
|
|
39
|
-
|
|
88
|
+
_initClass2();
|
|
40
89
|
}
|
|
41
90
|
}
|
|
42
91
|
class AppModule {}
|
|
@@ -64,17 +113,17 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
64
113
|
}
|
|
65
114
|
}
|
|
66
115
|
async assertPreservesRawBodyForJsonAndText() {
|
|
67
|
-
let
|
|
116
|
+
let _initProto3, _initClass3;
|
|
68
117
|
let _WebhookController;
|
|
69
118
|
class WebhookController {
|
|
70
119
|
static {
|
|
71
120
|
({
|
|
72
|
-
e: [
|
|
73
|
-
c: [_WebhookController,
|
|
121
|
+
e: [_initProto3],
|
|
122
|
+
c: [_WebhookController, _initClass3]
|
|
74
123
|
} = _applyDecs(this, [Controller('/webhooks')], [[Post('/json'), 2, "handleJson"], [Post('/text'), 2, "handleText"]]));
|
|
75
124
|
}
|
|
76
125
|
constructor() {
|
|
77
|
-
|
|
126
|
+
_initProto3(this);
|
|
78
127
|
}
|
|
79
128
|
handleJson(_input, context) {
|
|
80
129
|
return {
|
|
@@ -89,7 +138,7 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
89
138
|
};
|
|
90
139
|
}
|
|
91
140
|
static {
|
|
92
|
-
|
|
141
|
+
_initClass3();
|
|
93
142
|
}
|
|
94
143
|
}
|
|
95
144
|
class AppModule {}
|
|
@@ -139,17 +188,17 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
139
188
|
}
|
|
140
189
|
}
|
|
141
190
|
async assertExcludesRawBodyForMultipart() {
|
|
142
|
-
let
|
|
191
|
+
let _initProto4, _initClass4;
|
|
143
192
|
let _UploadController;
|
|
144
193
|
class UploadController {
|
|
145
194
|
static {
|
|
146
195
|
({
|
|
147
|
-
e: [
|
|
148
|
-
c: [_UploadController,
|
|
196
|
+
e: [_initProto4],
|
|
197
|
+
c: [_UploadController, _initClass4]
|
|
149
198
|
} = _applyDecs(this, [Controller('/uploads')], [[Post('/'), 2, "upload"]]));
|
|
150
199
|
}
|
|
151
200
|
constructor() {
|
|
152
|
-
|
|
201
|
+
_initProto4(this);
|
|
153
202
|
}
|
|
154
203
|
upload(_input, context) {
|
|
155
204
|
return {
|
|
@@ -159,7 +208,7 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
159
208
|
};
|
|
160
209
|
}
|
|
161
210
|
static {
|
|
162
|
-
|
|
211
|
+
_initClass4();
|
|
163
212
|
}
|
|
164
213
|
}
|
|
165
214
|
class AppModule {}
|
|
@@ -198,17 +247,17 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
198
247
|
}
|
|
199
248
|
}
|
|
200
249
|
async assertSupportsSseStreaming() {
|
|
201
|
-
let
|
|
250
|
+
let _initProto5, _initClass5;
|
|
202
251
|
let _EventsController;
|
|
203
252
|
class EventsController {
|
|
204
253
|
static {
|
|
205
254
|
({
|
|
206
|
-
e: [
|
|
207
|
-
c: [_EventsController,
|
|
255
|
+
e: [_initProto5],
|
|
256
|
+
c: [_EventsController, _initClass5]
|
|
208
257
|
} = _applyDecs(this, [Controller('/events')], [[Get('/'), 2, "stream"]]));
|
|
209
258
|
}
|
|
210
259
|
constructor() {
|
|
211
|
-
|
|
260
|
+
_initProto5(this);
|
|
212
261
|
}
|
|
213
262
|
stream(_input, context) {
|
|
214
263
|
const stream = new SseResponse(context);
|
|
@@ -223,7 +272,7 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
223
272
|
return stream;
|
|
224
273
|
}
|
|
225
274
|
static {
|
|
226
|
-
|
|
275
|
+
_initClass5();
|
|
227
276
|
}
|
|
228
277
|
}
|
|
229
278
|
class AppModule {}
|
|
@@ -255,6 +304,13 @@ export class WebRuntimeHttpAdapterPortabilityHarness {
|
|
|
255
304
|
}
|
|
256
305
|
}
|
|
257
306
|
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Create web runtime http adapter portability harness.
|
|
310
|
+
*
|
|
311
|
+
* @param options The options.
|
|
312
|
+
* @returns The create web runtime http adapter portability harness result.
|
|
313
|
+
*/
|
|
258
314
|
export function createWebRuntimeHttpAdapterPortabilityHarness(options) {
|
|
259
315
|
return new WebRuntimeHttpAdapterPortabilityHarness(options);
|
|
260
316
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mock } from 'vitest';
|
|
2
2
|
import type { MaybePromise, Token } from '@fluojs/core';
|
|
3
3
|
import type { ClassType, Container, ForwardRefFn, OptionalToken, Provider } from '@fluojs/di';
|
|
4
|
-
import type { BootstrapResult, BootstrapModuleOptions, ModuleType } from '@fluojs/runtime';
|
|
4
|
+
import type { BootstrapApplicationOptions, BootstrapResult, BootstrapModuleOptions, ModuleType } from '@fluojs/runtime';
|
|
5
5
|
import type { Guard, Interceptor } from '@fluojs/http';
|
|
6
6
|
import type { RequestBuilder, TestPrincipal, TestRequest, TestRequestWithOptions, TestResponse } from './http.js';
|
|
7
7
|
/**
|
|
@@ -10,6 +10,12 @@ import type { RequestBuilder, TestPrincipal, TestRequest, TestRequestWithOptions
|
|
|
10
10
|
export interface TestingModuleOptions extends BootstrapModuleOptions {
|
|
11
11
|
rootModule: ModuleType;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Bootstrap options accepted by `createTestApp(...)`.
|
|
15
|
+
*/
|
|
16
|
+
export interface TestingApplicationOptions extends BootstrapApplicationOptions {
|
|
17
|
+
rootModule: ModuleType;
|
|
18
|
+
}
|
|
13
19
|
/**
|
|
14
20
|
* Optional request extras accepted by `TestApp.request(...)` overloads.
|
|
15
21
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,eAAe,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxH,OAAO,K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U,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAAC;IACpF,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IAC9C,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,cAAc,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACtD,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC;CACT,CAAC"}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"override",
|
|
10
10
|
"module-builder"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.3",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"dist"
|
|
77
77
|
],
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@fluojs/
|
|
80
|
-
"@fluojs/
|
|
81
|
-
"@fluojs/
|
|
82
|
-
"@fluojs/
|
|
83
|
-
"@fluojs/
|
|
79
|
+
"@fluojs/core": "^1.0.0-beta.5",
|
|
80
|
+
"@fluojs/di": "^1.0.0-beta.7",
|
|
81
|
+
"@fluojs/runtime": "^1.0.0-beta.12",
|
|
82
|
+
"@fluojs/http": "^1.0.0-beta.10",
|
|
83
|
+
"@fluojs/config": "^1.0.0-beta.8"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@babel/core": ">=7.0.0",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"vitest": "^3.2.4",
|
|
91
|
-
"@fluojs/platform-
|
|
92
|
-
"@fluojs/platform-
|
|
93
|
-
"@fluojs/platform-fastify": "^1.0.0-beta.
|
|
91
|
+
"@fluojs/platform-express": "^1.0.0-beta.7",
|
|
92
|
+
"@fluojs/platform-nodejs": "^1.0.0-beta.5",
|
|
93
|
+
"@fluojs/platform-fastify": "^1.0.0-beta.8"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|