@stratal/testing 0.0.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/LICENSE +21 -0
- package/dist/core/env/index.d.ts +2 -0
- package/dist/core/env/index.d.ts.map +1 -0
- package/dist/core/env/index.js +2 -0
- package/dist/core/env/index.js.map +1 -0
- package/dist/core/env/test-env.d.ts +9 -0
- package/dist/core/env/test-env.d.ts.map +1 -0
- package/dist/core/env/test-env.js +14 -0
- package/dist/core/env/test-env.js.map +1 -0
- package/dist/core/http/fetch-mock.d.ts +236 -0
- package/dist/core/http/fetch-mock.d.ts.map +1 -0
- package/dist/core/http/fetch-mock.js +290 -0
- package/dist/core/http/fetch-mock.js.map +1 -0
- package/dist/core/http/fetch-mock.types.d.ts +48 -0
- package/dist/core/http/fetch-mock.types.d.ts.map +1 -0
- package/dist/core/http/fetch-mock.types.js +2 -0
- package/dist/core/http/fetch-mock.types.js.map +1 -0
- package/dist/core/http/index.d.ts +6 -0
- package/dist/core/http/index.d.ts.map +1 -0
- package/dist/core/http/index.js +5 -0
- package/dist/core/http/index.js.map +1 -0
- package/dist/core/http/test-http-client.d.ts +54 -0
- package/dist/core/http/test-http-client.d.ts.map +1 -0
- package/dist/core/http/test-http-client.js +75 -0
- package/dist/core/http/test-http-client.js.map +1 -0
- package/dist/core/http/test-http-request.d.ts +44 -0
- package/dist/core/http/test-http-request.d.ts.map +1 -0
- package/dist/core/http/test-http-request.js +75 -0
- package/dist/core/http/test-http-request.js.map +1 -0
- package/dist/core/http/test-response.d.ts +161 -0
- package/dist/core/http/test-response.d.ts.map +1 -0
- package/dist/core/http/test-response.js +309 -0
- package/dist/core/http/test-response.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/override/index.d.ts +2 -0
- package/dist/core/override/index.d.ts.map +1 -0
- package/dist/core/override/index.js +2 -0
- package/dist/core/override/index.js.map +1 -0
- package/dist/core/override/provider-override-builder.d.ts +77 -0
- package/dist/core/override/provider-override-builder.d.ts.map +1 -0
- package/dist/core/override/provider-override-builder.js +94 -0
- package/dist/core/override/provider-override-builder.js.map +1 -0
- package/dist/core/test.d.ts +48 -0
- package/dist/core/test.d.ts.map +1 -0
- package/dist/core/test.js +53 -0
- package/dist/core/test.js.map +1 -0
- package/dist/core/testing-module-builder.d.ts +98 -0
- package/dist/core/testing-module-builder.d.ts.map +1 -0
- package/dist/core/testing-module-builder.js +154 -0
- package/dist/core/testing-module-builder.js.map +1 -0
- package/dist/core/testing-module.d.ts +77 -0
- package/dist/core/testing-module.d.ts.map +1 -0
- package/dist/core/testing-module.js +99 -0
- package/dist/core/testing-module.js.map +1 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/setup-error.d.ts +9 -0
- package/dist/errors/setup-error.d.ts.map +1 -0
- package/dist/errors/setup-error.js +11 -0
- package/dist/errors/setup-error.js.map +1 -0
- package/dist/errors/test-error.d.ts +9 -0
- package/dist/errors/test-error.d.ts.map +1 -0
- package/dist/errors/test-error.js +15 -0
- package/dist/errors/test-error.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/mocks/index.d.ts +4 -0
- package/dist/mocks/index.d.ts.map +1 -0
- package/dist/mocks/index.js +4 -0
- package/dist/mocks/index.js.map +1 -0
- package/dist/mocks/nodemailer.d.ts +10 -0
- package/dist/mocks/nodemailer.d.ts.map +1 -0
- package/dist/mocks/nodemailer.js +9 -0
- package/dist/mocks/nodemailer.js.map +1 -0
- package/dist/storage/fake-storage.service.d.ts +114 -0
- package/dist/storage/fake-storage.service.d.ts.map +1 -0
- package/dist/storage/fake-storage.service.js +233 -0
- package/dist/storage/fake-storage.service.js.map +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TestingModule } from '../testing-module';
|
|
2
|
+
import { TestHttpRequest } from './test-http-request';
|
|
3
|
+
/**
|
|
4
|
+
* TestHttpClient
|
|
5
|
+
*
|
|
6
|
+
* Fluent HTTP client for making test requests.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const response = await module.http
|
|
11
|
+
* .forHost('school.admsn.test')
|
|
12
|
+
* .post('/api/v1/register')
|
|
13
|
+
* .withBody({ schoolInfo: { name: 'Test' } })
|
|
14
|
+
* .send()
|
|
15
|
+
*
|
|
16
|
+
* response.assertCreated()
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class TestHttpClient {
|
|
20
|
+
private readonly module;
|
|
21
|
+
private defaultHeaders;
|
|
22
|
+
private host;
|
|
23
|
+
constructor(module: TestingModule);
|
|
24
|
+
/**
|
|
25
|
+
* Set the host for the request (used for tenant identification)
|
|
26
|
+
*/
|
|
27
|
+
forHost(host: string): this;
|
|
28
|
+
/**
|
|
29
|
+
* Set default headers for all requests
|
|
30
|
+
*/
|
|
31
|
+
withHeaders(headers: Record<string, string>): this;
|
|
32
|
+
/**
|
|
33
|
+
* Create a GET request
|
|
34
|
+
*/
|
|
35
|
+
get(path: string): TestHttpRequest;
|
|
36
|
+
/**
|
|
37
|
+
* Create a POST request
|
|
38
|
+
*/
|
|
39
|
+
post(path: string): TestHttpRequest;
|
|
40
|
+
/**
|
|
41
|
+
* Create a PUT request
|
|
42
|
+
*/
|
|
43
|
+
put(path: string): TestHttpRequest;
|
|
44
|
+
/**
|
|
45
|
+
* Create a PATCH request
|
|
46
|
+
*/
|
|
47
|
+
patch(path: string): TestHttpRequest;
|
|
48
|
+
/**
|
|
49
|
+
* Create a DELETE request
|
|
50
|
+
*/
|
|
51
|
+
delete(path: string): TestHttpRequest;
|
|
52
|
+
private createRequest;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=test-http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-http-client.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,IAAI,CAAsB;gBAEL,MAAM,EAAE,aAAa;IAElD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK3B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOlD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAInC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIpC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIrC,OAAO,CAAC,aAAa;CAGtB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TestHttpRequest } from './test-http-request';
|
|
2
|
+
/**
|
|
3
|
+
* TestHttpClient
|
|
4
|
+
*
|
|
5
|
+
* Fluent HTTP client for making test requests.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const response = await module.http
|
|
10
|
+
* .forHost('school.admsn.test')
|
|
11
|
+
* .post('/api/v1/register')
|
|
12
|
+
* .withBody({ schoolInfo: { name: 'Test' } })
|
|
13
|
+
* .send()
|
|
14
|
+
*
|
|
15
|
+
* response.assertCreated()
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class TestHttpClient {
|
|
19
|
+
module;
|
|
20
|
+
defaultHeaders = new Headers();
|
|
21
|
+
host = null;
|
|
22
|
+
constructor(module) {
|
|
23
|
+
this.module = module;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set the host for the request (used for tenant identification)
|
|
27
|
+
*/
|
|
28
|
+
forHost(host) {
|
|
29
|
+
this.host = host;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set default headers for all requests
|
|
34
|
+
*/
|
|
35
|
+
withHeaders(headers) {
|
|
36
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
37
|
+
this.defaultHeaders.set(key, value);
|
|
38
|
+
}
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a GET request
|
|
43
|
+
*/
|
|
44
|
+
get(path) {
|
|
45
|
+
return this.createRequest('GET', path);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a POST request
|
|
49
|
+
*/
|
|
50
|
+
post(path) {
|
|
51
|
+
return this.createRequest('POST', path);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a PUT request
|
|
55
|
+
*/
|
|
56
|
+
put(path) {
|
|
57
|
+
return this.createRequest('PUT', path);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a PATCH request
|
|
61
|
+
*/
|
|
62
|
+
patch(path) {
|
|
63
|
+
return this.createRequest('PATCH', path);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a DELETE request
|
|
67
|
+
*/
|
|
68
|
+
delete(path) {
|
|
69
|
+
return this.createRequest('DELETE', path);
|
|
70
|
+
}
|
|
71
|
+
createRequest(method, path) {
|
|
72
|
+
return new TestHttpRequest(method, path, this.defaultHeaders, this.module, this.host);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=test-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-http-client.js","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAII;IAHrB,cAAc,GAAY,IAAI,OAAO,EAAE,CAAA;IACvC,IAAI,GAAkB,IAAI,CAAA;IAElC,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAI,CAAC;IAEvD;;OAEG;IACH,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAA+B;QACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;IAEO,aAAa,CAAC,MAAc,EAAE,IAAY;QAChD,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACvF,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TestingModule } from '../testing-module';
|
|
2
|
+
import { TestResponse } from './test-response';
|
|
3
|
+
/**
|
|
4
|
+
* TestHttpRequest
|
|
5
|
+
*
|
|
6
|
+
* Request builder with fluent API for configuring test HTTP requests.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const response = await module.http
|
|
11
|
+
* .post('/api/v1/register')
|
|
12
|
+
* .withBody({ name: 'Test School' })
|
|
13
|
+
* .withHeaders({ 'X-Custom': 'value' })
|
|
14
|
+
* .send()
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class TestHttpRequest {
|
|
18
|
+
private readonly method;
|
|
19
|
+
private readonly path;
|
|
20
|
+
private readonly module;
|
|
21
|
+
private readonly host;
|
|
22
|
+
private body;
|
|
23
|
+
private requestHeaders;
|
|
24
|
+
constructor(method: string, path: string, headers: Headers, module: TestingModule, host?: string | null);
|
|
25
|
+
/**
|
|
26
|
+
* Set the request body
|
|
27
|
+
*/
|
|
28
|
+
withBody(data: unknown): this;
|
|
29
|
+
/**
|
|
30
|
+
* Add headers to the request
|
|
31
|
+
*/
|
|
32
|
+
withHeaders(headers: Record<string, string>): this;
|
|
33
|
+
/**
|
|
34
|
+
* Set Content-Type to application/json
|
|
35
|
+
*/
|
|
36
|
+
asJson(): this;
|
|
37
|
+
/**
|
|
38
|
+
* Send the request and return response
|
|
39
|
+
*
|
|
40
|
+
* Calls module.fetch() - NOT SELF.fetch()
|
|
41
|
+
*/
|
|
42
|
+
send(): Promise<TestResponse>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=test-http-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-http-request.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-http-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAe;IAK1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IARtB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,cAAc,CAAS;gBAGb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC7B,OAAO,EAAE,OAAO,EACC,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE,MAAM,GAAG,IAAW;IAK5C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAK7B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOlD;;OAEG;IACH,MAAM,IAAI,IAAI;IAKd;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC;CAkBnC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TestResponse } from './test-response';
|
|
2
|
+
/**
|
|
3
|
+
* TestHttpRequest
|
|
4
|
+
*
|
|
5
|
+
* Request builder with fluent API for configuring test HTTP requests.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const response = await module.http
|
|
10
|
+
* .post('/api/v1/register')
|
|
11
|
+
* .withBody({ name: 'Test School' })
|
|
12
|
+
* .withHeaders({ 'X-Custom': 'value' })
|
|
13
|
+
* .send()
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class TestHttpRequest {
|
|
17
|
+
method;
|
|
18
|
+
path;
|
|
19
|
+
module;
|
|
20
|
+
host;
|
|
21
|
+
body = null;
|
|
22
|
+
requestHeaders;
|
|
23
|
+
constructor(method, path, headers, module, host = null) {
|
|
24
|
+
this.method = method;
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.module = module;
|
|
27
|
+
this.host = host;
|
|
28
|
+
this.requestHeaders = new Headers(headers);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set the request body
|
|
32
|
+
*/
|
|
33
|
+
withBody(data) {
|
|
34
|
+
this.body = data;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add headers to the request
|
|
39
|
+
*/
|
|
40
|
+
withHeaders(headers) {
|
|
41
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
42
|
+
this.requestHeaders.set(key, value);
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set Content-Type to application/json
|
|
48
|
+
*/
|
|
49
|
+
asJson() {
|
|
50
|
+
this.requestHeaders.set('Content-Type', 'application/json');
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Send the request and return response
|
|
55
|
+
*
|
|
56
|
+
* Calls module.fetch() - NOT SELF.fetch()
|
|
57
|
+
*/
|
|
58
|
+
async send() {
|
|
59
|
+
// Auto-set Content-Type for body
|
|
60
|
+
if (this.body && !this.requestHeaders.has('Content-Type')) {
|
|
61
|
+
this.requestHeaders.set('Content-Type', 'application/json');
|
|
62
|
+
}
|
|
63
|
+
// Build request
|
|
64
|
+
const url = new URL(this.path, `http://${this.host ?? 'localhost'}`);
|
|
65
|
+
const request = new Request(url.toString(), {
|
|
66
|
+
method: this.method,
|
|
67
|
+
headers: this.requestHeaders,
|
|
68
|
+
body: this.body ? JSON.stringify(this.body) : null,
|
|
69
|
+
});
|
|
70
|
+
// Call module.fetch() - NO SELF.fetch()
|
|
71
|
+
const response = await this.module.fetch(request);
|
|
72
|
+
return new TestResponse(response);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=test-http-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-http-request.js","sourceRoot":"","sources":["../../../src/core/http/test-http-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAe;IAKT;IACA;IAEA;IACA;IARV,IAAI,GAAY,IAAI,CAAA;IACpB,cAAc,CAAS;IAE/B,YACkB,MAAc,EACd,IAAY,EAC7B,OAAgB,EACC,MAAqB,EACrB,OAAsB,IAAI;QAJ1B,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAe;QACrB,SAAI,GAAJ,IAAI,CAAsB;QAE3C,IAAI,CAAC,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AA;QAEF,wCAAwC;QACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC;CACD"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TestResponse
|
|
3
|
+
*
|
|
4
|
+
* Wrapper around Response with assertion methods.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* response
|
|
9
|
+
* .assertOk()
|
|
10
|
+
* .assertStatus(200)
|
|
11
|
+
* .assertJsonPath('data.id', userId)
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class TestResponse {
|
|
15
|
+
private readonly response;
|
|
16
|
+
private jsonData;
|
|
17
|
+
private textData;
|
|
18
|
+
constructor(response: Response);
|
|
19
|
+
/**
|
|
20
|
+
* Get the raw Response object.
|
|
21
|
+
*/
|
|
22
|
+
get raw(): Response;
|
|
23
|
+
/**
|
|
24
|
+
* Get the response status code.
|
|
25
|
+
*/
|
|
26
|
+
get status(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Get response headers.
|
|
29
|
+
*/
|
|
30
|
+
get headers(): Headers;
|
|
31
|
+
/**
|
|
32
|
+
* Get the response body as JSON.
|
|
33
|
+
*/
|
|
34
|
+
json<T = unknown>(): Promise<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the response body as text.
|
|
37
|
+
*/
|
|
38
|
+
text(): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Assert response status is 200 OK.
|
|
41
|
+
*/
|
|
42
|
+
assertOk(): this;
|
|
43
|
+
/**
|
|
44
|
+
* Assert response status is 201 Created.
|
|
45
|
+
*/
|
|
46
|
+
assertCreated(): this;
|
|
47
|
+
/**
|
|
48
|
+
* Assert response status is 204 No Content.
|
|
49
|
+
*/
|
|
50
|
+
assertNoContent(): this;
|
|
51
|
+
/**
|
|
52
|
+
* Assert response status is 400 Bad Request.
|
|
53
|
+
*/
|
|
54
|
+
assertBadRequest(): this;
|
|
55
|
+
/**
|
|
56
|
+
* Assert response status is 401 Unauthorized.
|
|
57
|
+
*/
|
|
58
|
+
assertUnauthorized(): this;
|
|
59
|
+
/**
|
|
60
|
+
* Assert response status is 403 Forbidden.
|
|
61
|
+
*/
|
|
62
|
+
assertForbidden(): this;
|
|
63
|
+
/**
|
|
64
|
+
* Assert response status is 404 Not Found.
|
|
65
|
+
*/
|
|
66
|
+
assertNotFound(): this;
|
|
67
|
+
/**
|
|
68
|
+
* Assert response status is 422 Unprocessable Entity.
|
|
69
|
+
*/
|
|
70
|
+
assertUnprocessable(): this;
|
|
71
|
+
/**
|
|
72
|
+
* Assert response status is 500 Internal Server Error.
|
|
73
|
+
*/
|
|
74
|
+
assertServerError(): this;
|
|
75
|
+
/**
|
|
76
|
+
* Assert response has the given status code.
|
|
77
|
+
*/
|
|
78
|
+
assertStatus(expected: number): this;
|
|
79
|
+
/**
|
|
80
|
+
* Assert response status is in the 2xx success range.
|
|
81
|
+
*/
|
|
82
|
+
assertSuccessful(): this;
|
|
83
|
+
/**
|
|
84
|
+
* Assert JSON response contains the given data.
|
|
85
|
+
*/
|
|
86
|
+
assertJson(expected: Record<string, unknown>): Promise<this>;
|
|
87
|
+
/**
|
|
88
|
+
* Assert JSON response has value at the given path.
|
|
89
|
+
*
|
|
90
|
+
* @param path - Dot-notation path (e.g., 'data.user.id')
|
|
91
|
+
* @param expected - Expected value at path
|
|
92
|
+
*/
|
|
93
|
+
assertJsonPath(path: string, expected: unknown): Promise<this>;
|
|
94
|
+
/**
|
|
95
|
+
* Assert JSON response structure matches the given schema.
|
|
96
|
+
*/
|
|
97
|
+
assertJsonStructure(structure: string[]): Promise<this>;
|
|
98
|
+
/**
|
|
99
|
+
* Assert a JSON path exists (value can be anything, including null).
|
|
100
|
+
*
|
|
101
|
+
* @param path - Dot-notation path (e.g., 'data.user.id')
|
|
102
|
+
*/
|
|
103
|
+
assertJsonPathExists(path: string): Promise<this>;
|
|
104
|
+
/**
|
|
105
|
+
* Assert a JSON path does not exist.
|
|
106
|
+
*
|
|
107
|
+
* @param path - Dot-notation path (e.g., 'data.user.deletedAt')
|
|
108
|
+
*/
|
|
109
|
+
assertJsonPathMissing(path: string): Promise<this>;
|
|
110
|
+
/**
|
|
111
|
+
* Assert JSON value at path matches a custom predicate.
|
|
112
|
+
*
|
|
113
|
+
* @param path - Dot-notation path (e.g., 'data.items')
|
|
114
|
+
* @param matcher - Predicate function to validate the value
|
|
115
|
+
*/
|
|
116
|
+
assertJsonPathMatches(path: string, matcher: (value: unknown) => boolean): Promise<this>;
|
|
117
|
+
/**
|
|
118
|
+
* Assert string value at path contains a substring.
|
|
119
|
+
*
|
|
120
|
+
* @param path - Dot-notation path (e.g., 'data.message')
|
|
121
|
+
* @param substring - Substring to search for
|
|
122
|
+
*/
|
|
123
|
+
assertJsonPathContains(path: string, substring: string): Promise<this>;
|
|
124
|
+
/**
|
|
125
|
+
* Assert array value at path includes a specific item.
|
|
126
|
+
*
|
|
127
|
+
* @param path - Dot-notation path (e.g., 'data.tags')
|
|
128
|
+
* @param item - Item to search for in the array
|
|
129
|
+
*/
|
|
130
|
+
assertJsonPathIncludes(path: string, item: unknown): Promise<this>;
|
|
131
|
+
/**
|
|
132
|
+
* Assert array length at path equals the expected count.
|
|
133
|
+
*
|
|
134
|
+
* @param path - Dot-notation path (e.g., 'data.items')
|
|
135
|
+
* @param count - Expected array length
|
|
136
|
+
*/
|
|
137
|
+
assertJsonPathCount(path: string, count: number): Promise<this>;
|
|
138
|
+
/**
|
|
139
|
+
* Assert multiple JSON paths at once (batch assertion).
|
|
140
|
+
*
|
|
141
|
+
* @param expectations - Object mapping paths to expected values
|
|
142
|
+
*/
|
|
143
|
+
assertJsonPaths(expectations: Record<string, unknown>): Promise<this>;
|
|
144
|
+
/**
|
|
145
|
+
* Assert response has the given header.
|
|
146
|
+
*/
|
|
147
|
+
assertHeader(name: string, expected?: string): this;
|
|
148
|
+
/**
|
|
149
|
+
* Assert response does not have the given header.
|
|
150
|
+
*/
|
|
151
|
+
assertHeaderMissing(name: string): this;
|
|
152
|
+
/**
|
|
153
|
+
* Get value at dot-notation path.
|
|
154
|
+
*/
|
|
155
|
+
private getValueAtPath;
|
|
156
|
+
/**
|
|
157
|
+
* Check if a path exists in the object (even if value is null/undefined).
|
|
158
|
+
*/
|
|
159
|
+
private hasValueAtPath;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=test-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-response.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-response.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAAsB;gBAET,QAAQ,EAAE,QAAQ;IAE/C;;OAEG;IACH,IAAI,GAAG,IAAI,QAAQ,CAElB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACG,IAAI,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC;IAOrC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAS7B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,aAAa,IAAI,IAAI;IAIrB;;OAEG;IACH,eAAe,IAAI,IAAI;IAIvB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAIxB;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,eAAe,IAAI,IAAI;IAIvB;;OAEG;IACH,cAAc,IAAI,IAAI;IAItB;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAI3B;;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