@stratal/testing 0.0.1 → 0.0.2
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.md +332 -0
- package/package.json +10 -10
- package/dist/core/env/index.d.ts +0 -2
- package/dist/core/env/index.d.ts.map +0 -1
- package/dist/core/env/index.js +0 -2
- package/dist/core/env/index.js.map +0 -1
- package/dist/core/env/test-env.d.ts +0 -9
- package/dist/core/env/test-env.d.ts.map +0 -1
- package/dist/core/env/test-env.js +0 -14
- package/dist/core/env/test-env.js.map +0 -1
- package/dist/core/http/fetch-mock.d.ts +0 -236
- package/dist/core/http/fetch-mock.d.ts.map +0 -1
- package/dist/core/http/fetch-mock.js +0 -290
- package/dist/core/http/fetch-mock.js.map +0 -1
- package/dist/core/http/fetch-mock.types.d.ts +0 -48
- package/dist/core/http/fetch-mock.types.d.ts.map +0 -1
- package/dist/core/http/fetch-mock.types.js +0 -2
- package/dist/core/http/fetch-mock.types.js.map +0 -1
- package/dist/core/http/index.d.ts +0 -6
- package/dist/core/http/index.d.ts.map +0 -1
- package/dist/core/http/index.js +0 -5
- package/dist/core/http/index.js.map +0 -1
- package/dist/core/http/test-http-client.d.ts +0 -54
- package/dist/core/http/test-http-client.d.ts.map +0 -1
- package/dist/core/http/test-http-client.js +0 -75
- package/dist/core/http/test-http-client.js.map +0 -1
- package/dist/core/http/test-http-request.d.ts +0 -44
- package/dist/core/http/test-http-request.d.ts.map +0 -1
- package/dist/core/http/test-http-request.js +0 -75
- package/dist/core/http/test-http-request.js.map +0 -1
- package/dist/core/http/test-response.d.ts +0 -161
- package/dist/core/http/test-response.d.ts.map +0 -1
- package/dist/core/http/test-response.js +0 -309
- package/dist/core/http/test-response.js.map +0 -1
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -7
- package/dist/core/index.js.map +0 -1
- package/dist/core/override/index.d.ts +0 -2
- package/dist/core/override/index.d.ts.map +0 -1
- package/dist/core/override/index.js +0 -2
- package/dist/core/override/index.js.map +0 -1
- package/dist/core/override/provider-override-builder.d.ts +0 -77
- package/dist/core/override/provider-override-builder.d.ts.map +0 -1
- package/dist/core/override/provider-override-builder.js +0 -94
- package/dist/core/override/provider-override-builder.js.map +0 -1
- package/dist/core/test.d.ts +0 -48
- package/dist/core/test.d.ts.map +0 -1
- package/dist/core/test.js +0 -53
- package/dist/core/test.js.map +0 -1
- package/dist/core/testing-module-builder.d.ts +0 -98
- package/dist/core/testing-module-builder.d.ts.map +0 -1
- package/dist/core/testing-module-builder.js +0 -154
- package/dist/core/testing-module-builder.js.map +0 -1
- package/dist/core/testing-module.d.ts +0 -77
- package/dist/core/testing-module.d.ts.map +0 -1
- package/dist/core/testing-module.js +0 -99
- package/dist/core/testing-module.js.map +0 -1
- package/dist/errors/index.d.ts +0 -3
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -3
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/setup-error.d.ts +0 -9
- package/dist/errors/setup-error.d.ts.map +0 -1
- package/dist/errors/setup-error.js +0 -11
- package/dist/errors/setup-error.js.map +0 -1
- package/dist/errors/test-error.d.ts +0 -9
- package/dist/errors/test-error.d.ts.map +0 -1
- package/dist/errors/test-error.js +0 -15
- package/dist/errors/test-error.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/mocks/index.d.ts +0 -4
- package/dist/mocks/index.d.ts.map +0 -1
- package/dist/mocks/index.js +0 -4
- package/dist/mocks/index.js.map +0 -1
- package/dist/mocks/nodemailer.d.ts +0 -10
- package/dist/mocks/nodemailer.d.ts.map +0 -1
- package/dist/mocks/nodemailer.js +0 -9
- package/dist/mocks/nodemailer.js.map +0 -1
- package/dist/storage/fake-storage.service.d.ts +0 -114
- package/dist/storage/fake-storage.service.d.ts.map +0 -1
- package/dist/storage/fake-storage.service.js +0 -233
- package/dist/storage/fake-storage.service.js.map +0 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -2
- package/dist/storage/index.js.map +0 -1
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fluent builder for provider overrides
|
|
3
|
-
*
|
|
4
|
-
* Provides a NestJS-style API for overriding providers in tests.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const module = await Test.createTestingModule({
|
|
9
|
-
* imports: [RegistrationModule],
|
|
10
|
-
* })
|
|
11
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
12
|
-
* .useValue(mockEmailService)
|
|
13
|
-
* .compile()
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export class ProviderOverrideBuilder {
|
|
17
|
-
parent;
|
|
18
|
-
token;
|
|
19
|
-
constructor(parent, token) {
|
|
20
|
-
this.parent = parent;
|
|
21
|
-
this.token = token;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Use a static value as the provider
|
|
25
|
-
*
|
|
26
|
-
* The value will be registered directly in the container.
|
|
27
|
-
*
|
|
28
|
-
* @param value - The value to use as the provider
|
|
29
|
-
* @returns The parent TestingModuleBuilder for chaining
|
|
30
|
-
*/
|
|
31
|
-
useValue(value) {
|
|
32
|
-
return this.parent.addProviderOverride({
|
|
33
|
-
token: this.token,
|
|
34
|
-
type: 'value',
|
|
35
|
-
implementation: value,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Use a class as the provider
|
|
40
|
-
*
|
|
41
|
-
* The class will be registered as a singleton.
|
|
42
|
-
*
|
|
43
|
-
* @param cls - The class constructor to use as the provider
|
|
44
|
-
* @returns The parent TestingModuleBuilder for chaining
|
|
45
|
-
*/
|
|
46
|
-
useClass(cls) {
|
|
47
|
-
return this.parent.addProviderOverride({
|
|
48
|
-
token: this.token,
|
|
49
|
-
type: 'class',
|
|
50
|
-
implementation: cls,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Use a factory function as the provider
|
|
55
|
-
*
|
|
56
|
-
* The factory receives the container and should return the provider instance.
|
|
57
|
-
*
|
|
58
|
-
* @param factory - Factory function that creates the provider
|
|
59
|
-
* @returns The parent TestingModuleBuilder for chaining
|
|
60
|
-
*/
|
|
61
|
-
useFactory(factory) {
|
|
62
|
-
return this.parent.addProviderOverride({
|
|
63
|
-
token: this.token,
|
|
64
|
-
type: 'factory',
|
|
65
|
-
implementation: factory,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Use an existing token as the provider (alias)
|
|
70
|
-
*
|
|
71
|
-
* The override token will resolve to the same instance as the target token.
|
|
72
|
-
*
|
|
73
|
-
* @param existingToken - The token to alias
|
|
74
|
-
* @returns The parent TestingModuleBuilder for chaining
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* const module = await Test.createTestingModule({
|
|
79
|
-
* imports: [MyModule],
|
|
80
|
-
* })
|
|
81
|
-
* .overrideProvider(ABSTRACT_TOKEN)
|
|
82
|
-
* .useExisting(ConcreteService)
|
|
83
|
-
* .compile()
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
useExisting(existingToken) {
|
|
87
|
-
return this.parent.addProviderOverride({
|
|
88
|
-
token: this.token,
|
|
89
|
-
type: 'existing',
|
|
90
|
-
implementation: existingToken,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=provider-override-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-override-builder.js","sourceRoot":"","sources":["../../../src/core/override/provider-override-builder.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,uBAAuB;IAEf;IACA;IAFnB,YACmB,MAA4B,EAC5B,KAAwB;QADxB,WAAM,GAAN,MAAM,CAAsB;QAC5B,UAAK,GAAL,KAAK,CAAmB;IACvC,CAAC;IAEL;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAQ;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,OAAO;YACb,cAAc,EAAE,KAAK;SACtB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAkC;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,OAAO;YACb,cAAc,EAAE,GAAG;SACpB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,OAAoC;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,SAAS;YACf,cAAc,EAAE,OAAO;SACxB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,aAAgC;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;YACrC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,UAAU;YAChB,cAAc,EAAE,aAAa;SAC9B,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/core/test.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { DynamicModule, ModuleClass } from 'stratal';
|
|
2
|
-
import { TestingModuleBuilder, type TestingModuleConfig } from './testing-module-builder';
|
|
3
|
-
/**
|
|
4
|
-
* Test
|
|
5
|
-
*
|
|
6
|
-
* Static class for creating testing modules.
|
|
7
|
-
* Provides a NestJS-style API for configuring test modules.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // In vitest.setup.ts:
|
|
12
|
-
* Test.setBaseModules([CoreModule])
|
|
13
|
-
*
|
|
14
|
-
* // In test files:
|
|
15
|
-
* const module = await Test.createTestingModule({
|
|
16
|
-
* imports: [RegistrationModule, GeoModule],
|
|
17
|
-
* })
|
|
18
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
19
|
-
* .useValue(mockEmailService)
|
|
20
|
-
* .compile()
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare class Test {
|
|
24
|
-
/**
|
|
25
|
-
* Base modules to include in all test modules
|
|
26
|
-
* Set once in vitest.setup.ts
|
|
27
|
-
*/
|
|
28
|
-
private static baseModules;
|
|
29
|
-
/**
|
|
30
|
-
* Set base modules to include in all test modules
|
|
31
|
-
* Should be called once in vitest.setup.ts
|
|
32
|
-
*
|
|
33
|
-
* @param modules - Modules to include before test-specific modules (e.g., CoreModule)
|
|
34
|
-
*/
|
|
35
|
-
static setBaseModules(modules: (ModuleClass | DynamicModule)[]): void;
|
|
36
|
-
/**
|
|
37
|
-
* Get base modules
|
|
38
|
-
*/
|
|
39
|
-
static getBaseModules(): (ModuleClass | DynamicModule)[];
|
|
40
|
-
/**
|
|
41
|
-
* Create a testing module builder
|
|
42
|
-
*
|
|
43
|
-
* @param config - Configuration with modules and optional env overrides
|
|
44
|
-
* @returns TestingModuleBuilder for configuring and compiling the module
|
|
45
|
-
*/
|
|
46
|
-
static createTestingModule(config: TestingModuleConfig): TestingModuleBuilder;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=test.d.ts.map
|
package/dist/core/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,IAAI;IACf;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW,CAAsC;IAEhE;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,aAAa,CAAC,EAAE,GAAG,IAAI;IAIrE;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,EAAE;IAIxD;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,oBAAoB;CAG9E"}
|
package/dist/core/test.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { TestingModuleBuilder } from './testing-module-builder';
|
|
2
|
-
/**
|
|
3
|
-
* Test
|
|
4
|
-
*
|
|
5
|
-
* Static class for creating testing modules.
|
|
6
|
-
* Provides a NestJS-style API for configuring test modules.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // In vitest.setup.ts:
|
|
11
|
-
* Test.setBaseModules([CoreModule])
|
|
12
|
-
*
|
|
13
|
-
* // In test files:
|
|
14
|
-
* const module = await Test.createTestingModule({
|
|
15
|
-
* imports: [RegistrationModule, GeoModule],
|
|
16
|
-
* })
|
|
17
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
18
|
-
* .useValue(mockEmailService)
|
|
19
|
-
* .compile()
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export class Test {
|
|
23
|
-
/**
|
|
24
|
-
* Base modules to include in all test modules
|
|
25
|
-
* Set once in vitest.setup.ts
|
|
26
|
-
*/
|
|
27
|
-
static baseModules = [];
|
|
28
|
-
/**
|
|
29
|
-
* Set base modules to include in all test modules
|
|
30
|
-
* Should be called once in vitest.setup.ts
|
|
31
|
-
*
|
|
32
|
-
* @param modules - Modules to include before test-specific modules (e.g., CoreModule)
|
|
33
|
-
*/
|
|
34
|
-
static setBaseModules(modules) {
|
|
35
|
-
this.baseModules = modules;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get base modules
|
|
39
|
-
*/
|
|
40
|
-
static getBaseModules() {
|
|
41
|
-
return this.baseModules;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Create a testing module builder
|
|
45
|
-
*
|
|
46
|
-
* @param config - Configuration with modules and optional env overrides
|
|
47
|
-
* @returns TestingModuleBuilder for configuring and compiling the module
|
|
48
|
-
*/
|
|
49
|
-
static createTestingModule(config) {
|
|
50
|
-
return new TestingModuleBuilder(config);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=test.js.map
|
package/dist/core/test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/core/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA4B,MAAM,0BAA0B,CAAA;AAEzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,IAAI;IACf;;;OAGG;IACK,MAAM,CAAC,WAAW,GAAoC,EAAE,CAAA;IAEhE;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,OAAwC;QAC5D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,MAA2B;QACpD,OAAO,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { ApplicationConfig, InjectionToken, type ModuleOptions, type StratalEnv } from 'stratal';
|
|
2
|
-
import { ProviderOverrideBuilder, type ProviderOverrideConfig } from './override';
|
|
3
|
-
import { TestingModule } from './testing-module';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for creating a testing module
|
|
6
|
-
*
|
|
7
|
-
* Extends ModuleOptions to support all module properties like NestJS.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const module = await Test.createTestingModule({
|
|
12
|
-
* imports: [RegistrationModule, GeoModule],
|
|
13
|
-
* providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
14
|
-
* controllers: [TestController],
|
|
15
|
-
* }).compile()
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export interface TestingModuleConfig extends ModuleOptions {
|
|
19
|
-
/** Optional environment overrides */
|
|
20
|
-
env?: Partial<StratalEnv>;
|
|
21
|
-
/** Logging configuration. Defaults: level=ERROR, formatter='json' */
|
|
22
|
-
logging?: ApplicationConfig['logging'];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Builder for creating test modules with provider overrides
|
|
26
|
-
*
|
|
27
|
-
* Provides a NestJS-style fluent API for configuring test modules.
|
|
28
|
-
* Supports all ModuleOptions properties (imports, providers, controllers, consumers, jobs).
|
|
29
|
-
*
|
|
30
|
-
* @example Basic usage
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const module = await Test.createTestingModule({
|
|
33
|
-
* imports: [RegistrationModule],
|
|
34
|
-
* }).compile()
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example Provider override
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const module = await Test.createTestingModule({
|
|
40
|
-
* imports: [RegistrationModule, GeoModule],
|
|
41
|
-
* })
|
|
42
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
43
|
-
* .useValue(mockEmailService)
|
|
44
|
-
* .compile()
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Full ModuleOptions
|
|
48
|
-
* ```typescript
|
|
49
|
-
* const module = await Test.createTestingModule({
|
|
50
|
-
* imports: [RegistrationModule],
|
|
51
|
-
* providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
52
|
-
* controllers: [TestController],
|
|
53
|
-
* consumers: [TestConsumer],
|
|
54
|
-
* jobs: [TestJob],
|
|
55
|
-
* }).compile()
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare class TestingModuleBuilder {
|
|
59
|
-
private config;
|
|
60
|
-
private overrides;
|
|
61
|
-
constructor(config: TestingModuleConfig);
|
|
62
|
-
/**
|
|
63
|
-
* Override a provider with a custom implementation
|
|
64
|
-
*
|
|
65
|
-
* Returns a ProviderOverrideBuilder for specifying the override type.
|
|
66
|
-
*
|
|
67
|
-
* @param token - The injection token to override
|
|
68
|
-
* @returns ProviderOverrideBuilder for chaining useValue/useClass/useFactory
|
|
69
|
-
*/
|
|
70
|
-
overrideProvider<T>(token: InjectionToken<T>): ProviderOverrideBuilder<T>;
|
|
71
|
-
/**
|
|
72
|
-
* Add a provider override (internal use by ProviderOverrideBuilder)
|
|
73
|
-
*
|
|
74
|
-
* @internal
|
|
75
|
-
*/
|
|
76
|
-
addProviderOverride<T>(override: ProviderOverrideConfig<T>): this;
|
|
77
|
-
/**
|
|
78
|
-
* Merge additional environment bindings
|
|
79
|
-
*
|
|
80
|
-
* @param env - Partial environment to merge
|
|
81
|
-
* @returns This builder for chaining
|
|
82
|
-
*/
|
|
83
|
-
withEnv(env: Partial<StratalEnv>): this;
|
|
84
|
-
/**
|
|
85
|
-
* Compile the testing module
|
|
86
|
-
*
|
|
87
|
-
* Creates the Application, applies overrides, initializes, and returns TestingModule.
|
|
88
|
-
* The ModuleRegistry handles all module registrations automatically.
|
|
89
|
-
*
|
|
90
|
-
* @returns Promise<TestingModule> - The compiled testing module
|
|
91
|
-
*/
|
|
92
|
-
compile(): Promise<TestingModule>;
|
|
93
|
-
/**
|
|
94
|
-
* Create a test root module with the given options
|
|
95
|
-
*/
|
|
96
|
-
private createTestRootModule;
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=testing-module-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.d.ts","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,cAAc,EAKd,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,SAAS,CAAA;AAKhB,OAAO,EAAE,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,qCAAqC;IACrC,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IACzB,qEAAqE;IACrE,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,oBAAoB;IAGnB,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAuC;gBAEpC,MAAM,EAAE,mBAAmB;IAE/C;;;;;;;OAOG;IACH,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CAAC;IAIzE;;;;OAIG;IACH,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,IAAI;IAKjE;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAKvC;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAmEvC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Application, LogLevel, Module, } from 'stratal';
|
|
8
|
-
import { STORAGE_TOKENS } from 'stratal/storage';
|
|
9
|
-
import { createExecutionContext } from 'cloudflare:test';
|
|
10
|
-
import { FakeStorageService } from '../storage';
|
|
11
|
-
import { getTestEnv } from './env';
|
|
12
|
-
import { ProviderOverrideBuilder } from './override';
|
|
13
|
-
import { Test } from './test';
|
|
14
|
-
import { TestingModule } from './testing-module';
|
|
15
|
-
/**
|
|
16
|
-
* Builder for creating test modules with provider overrides
|
|
17
|
-
*
|
|
18
|
-
* Provides a NestJS-style fluent API for configuring test modules.
|
|
19
|
-
* Supports all ModuleOptions properties (imports, providers, controllers, consumers, jobs).
|
|
20
|
-
*
|
|
21
|
-
* @example Basic usage
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const module = await Test.createTestingModule({
|
|
24
|
-
* imports: [RegistrationModule],
|
|
25
|
-
* }).compile()
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example Provider override
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const module = await Test.createTestingModule({
|
|
31
|
-
* imports: [RegistrationModule, GeoModule],
|
|
32
|
-
* })
|
|
33
|
-
* .overrideProvider(EMAIL_TOKENS.EmailService)
|
|
34
|
-
* .useValue(mockEmailService)
|
|
35
|
-
* .compile()
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @example Full ModuleOptions
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const module = await Test.createTestingModule({
|
|
41
|
-
* imports: [RegistrationModule],
|
|
42
|
-
* providers: [{ provide: MOCK_TOKEN, useValue: mockValue }],
|
|
43
|
-
* controllers: [TestController],
|
|
44
|
-
* consumers: [TestConsumer],
|
|
45
|
-
* jobs: [TestJob],
|
|
46
|
-
* }).compile()
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export class TestingModuleBuilder {
|
|
50
|
-
config;
|
|
51
|
-
overrides = [];
|
|
52
|
-
constructor(config) {
|
|
53
|
-
this.config = config;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Override a provider with a custom implementation
|
|
57
|
-
*
|
|
58
|
-
* Returns a ProviderOverrideBuilder for specifying the override type.
|
|
59
|
-
*
|
|
60
|
-
* @param token - The injection token to override
|
|
61
|
-
* @returns ProviderOverrideBuilder for chaining useValue/useClass/useFactory
|
|
62
|
-
*/
|
|
63
|
-
overrideProvider(token) {
|
|
64
|
-
return new ProviderOverrideBuilder(this, token);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Add a provider override (internal use by ProviderOverrideBuilder)
|
|
68
|
-
*
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
addProviderOverride(override) {
|
|
72
|
-
this.overrides.push(override);
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Merge additional environment bindings
|
|
77
|
-
*
|
|
78
|
-
* @param env - Partial environment to merge
|
|
79
|
-
* @returns This builder for chaining
|
|
80
|
-
*/
|
|
81
|
-
withEnv(env) {
|
|
82
|
-
this.config.env = { ...this.config.env, ...env };
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Compile the testing module
|
|
87
|
-
*
|
|
88
|
-
* Creates the Application, applies overrides, initializes, and returns TestingModule.
|
|
89
|
-
* The ModuleRegistry handles all module registrations automatically.
|
|
90
|
-
*
|
|
91
|
-
* @returns Promise<TestingModule> - The compiled testing module
|
|
92
|
-
*/
|
|
93
|
-
async compile() {
|
|
94
|
-
// 1. Create environment (cloudflare:test base + overrides)
|
|
95
|
-
const env = getTestEnv(this.config.env);
|
|
96
|
-
// 2. Create ExecutionContext
|
|
97
|
-
const ctx = createExecutionContext();
|
|
98
|
-
// 3. Build root module from config (supports all ModuleOptions)
|
|
99
|
-
const baseModules = Test.getBaseModules();
|
|
100
|
-
const configImports = this.config.imports ?? [];
|
|
101
|
-
const allImports = [...baseModules, ...configImports];
|
|
102
|
-
// Create root module with all config properties
|
|
103
|
-
const rootModule = this.createTestRootModule({
|
|
104
|
-
imports: allImports,
|
|
105
|
-
providers: this.config.providers,
|
|
106
|
-
controllers: this.config.controllers,
|
|
107
|
-
consumers: this.config.consumers,
|
|
108
|
-
jobs: this.config.jobs,
|
|
109
|
-
});
|
|
110
|
-
// 4. Create Application
|
|
111
|
-
const app = new Application(env, ctx, {
|
|
112
|
-
module: rootModule,
|
|
113
|
-
logging: {
|
|
114
|
-
level: this.config.logging?.level ?? LogLevel.ERROR,
|
|
115
|
-
formatter: this.config.logging?.formatter ?? 'pretty',
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
// 7. Initialize application - ModuleRegistry handles all module registrations
|
|
119
|
-
await app.initialize();
|
|
120
|
-
// 5. Auto-register FakeStorageService as singleton (can be overridden by user)
|
|
121
|
-
// Must be singleton so files uploaded in setup are available when consumers run
|
|
122
|
-
app.container.registerSingleton(STORAGE_TOKENS.StorageService, FakeStorageService);
|
|
123
|
-
// 6. Apply user overrides BEFORE initialize
|
|
124
|
-
for (const override of this.overrides) {
|
|
125
|
-
switch (override.type) {
|
|
126
|
-
case 'value':
|
|
127
|
-
app.container.registerValue(override.token, override.implementation);
|
|
128
|
-
break;
|
|
129
|
-
case 'class':
|
|
130
|
-
app.container.registerSingleton(override.token, override.implementation);
|
|
131
|
-
break;
|
|
132
|
-
case 'factory':
|
|
133
|
-
app.container.registerFactory(override.token, override.implementation);
|
|
134
|
-
break;
|
|
135
|
-
case 'existing':
|
|
136
|
-
app.container.registerExisting(override.token, override.implementation);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return new TestingModule(app, env);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Create a test root module with the given options
|
|
144
|
-
*/
|
|
145
|
-
createTestRootModule(options) {
|
|
146
|
-
let TestRootModule = class TestRootModule {
|
|
147
|
-
};
|
|
148
|
-
TestRootModule = __decorate([
|
|
149
|
-
Module(options)
|
|
150
|
-
], TestRootModule);
|
|
151
|
-
return TestRootModule;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=testing-module-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module-builder.js","sourceRoot":"","sources":["../../src/core/testing-module-builder.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,WAAW,EAIX,QAAQ,EACR,MAAM,GAKP,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,uBAAuB,EAA+B,MAAM,YAAY,CAAA;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,oBAAoB;IAGX;IAFZ,SAAS,GAAqC,EAAE,CAAA;IAExD,YAAoB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAI,CAAC;IAEpD;;;;;;;OAOG;IACH,gBAAgB,CAAI,KAAwB;QAC1C,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAI,QAAmC;QACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAA0C,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,GAAwB;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAA;QAChD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO;QACX,2DAA2D;QAC3D,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAEvC,6BAA6B;QAC7B,MAAM,GAAG,GAAG,sBAAsB,EAAE,CAAA;QAEpC,gEAAgE;QAChE,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;QAC/C,MAAM,UAAU,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,CAAA;QAErD,gDAAgD;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC;YAC3C,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;YACpC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SACvB,CAAC,CAAA;QAEF,wBAAwB;QACxB,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;YACpC,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE;gBACP,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,IAAI,QAAQ,CAAC,KAAK;gBACnD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,QAAQ;aACtD;SACF,CAAC,CAAA;QAEF,8EAA8E;QAC9E,MAAM,GAAG,CAAC,UAAU,EAAE,CAAA;QAEtB,+EAA+E;QAC/E,gFAAgF;QAChF,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;QAElF,4CAA4C;QAC5C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACtB,KAAK,OAAO;oBACV,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;oBACpE,MAAK;gBACP,KAAK,OAAO;oBACV,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAC7B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAA6B,CACvC,CAAA;oBACD,MAAK;gBACP,KAAK,SAAS;oBACZ,GAAG,CAAC,SAAS,CAAC,eAAe,CAC3B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAA0C,CACpD,CAAA;oBACD,MAAK;gBACP,KAAK,UAAU;oBACb,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAC5B,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,cAAwC,CAClD,CAAA;oBACD,MAAK;YACT,CAAC;QACH,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC;IAED;;OAEG;IACK,oBAAoB,CAAC,OAAsB;QAEjD,IAAM,cAAc,GAApB,MAAM,cAAc;SAAI,CAAA;QAAlB,cAAc;YADnB,MAAM,CAAC,OAAO,CAAC;WACV,cAAc,CAAI;QACxB,OAAO,cAAc,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Application, Container, InjectionToken, StratalEnv } from 'stratal';
|
|
2
|
-
import type { FakeStorageService } from '../storage';
|
|
3
|
-
import { TestHttpClient } from './http/test-http-client';
|
|
4
|
-
/**
|
|
5
|
-
* TestingModule
|
|
6
|
-
*
|
|
7
|
-
* Provides access to the test application, container, HTTP client, and utilities.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const module = await Test.createTestingModule({
|
|
12
|
-
* modules: [RegistrationModule],
|
|
13
|
-
* }).compile()
|
|
14
|
-
*
|
|
15
|
-
* // Make HTTP requests
|
|
16
|
-
* const response = await module.http
|
|
17
|
-
* .post('/api/v1/register')
|
|
18
|
-
* .withBody({ ... })
|
|
19
|
-
* .send()
|
|
20
|
-
*
|
|
21
|
-
* // Access services
|
|
22
|
-
* const service = module.get(REGISTRATION_TOKENS.RegistrationService)
|
|
23
|
-
*
|
|
24
|
-
* // Cleanup
|
|
25
|
-
* await module.close()
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare class TestingModule {
|
|
29
|
-
private readonly app;
|
|
30
|
-
private readonly env;
|
|
31
|
-
private _http;
|
|
32
|
-
constructor(app: Application, env: StratalEnv);
|
|
33
|
-
/**
|
|
34
|
-
* Resolve a service from the container
|
|
35
|
-
*/
|
|
36
|
-
get<T>(token: InjectionToken<T>): T;
|
|
37
|
-
/**
|
|
38
|
-
* Get HTTP test client for making requests
|
|
39
|
-
*/
|
|
40
|
-
get http(): TestHttpClient;
|
|
41
|
-
/**
|
|
42
|
-
* Get fake storage service for assertions
|
|
43
|
-
*
|
|
44
|
-
* Provides assertion helpers for testing file storage operations.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* module.storage.assertExists('path/to/file.pdf')
|
|
49
|
-
* module.storage.assertMissing('deleted/file.pdf')
|
|
50
|
-
* module.storage.clear() // Reset between tests
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
get storage(): FakeStorageService;
|
|
54
|
-
/**
|
|
55
|
-
* Get Application instance
|
|
56
|
-
*/
|
|
57
|
-
get application(): Application;
|
|
58
|
-
/**
|
|
59
|
-
* Get DI Container
|
|
60
|
-
*/
|
|
61
|
-
get container(): Container;
|
|
62
|
-
/**
|
|
63
|
-
* Execute an HTTP request through RouterService
|
|
64
|
-
*
|
|
65
|
-
* This is the core method - calls RouterService.fetch() directly, no SELF.fetch()
|
|
66
|
-
*/
|
|
67
|
-
fetch(request: Request): Promise<Response>;
|
|
68
|
-
/**
|
|
69
|
-
* Run callback in request scope (for DB operations, service access)
|
|
70
|
-
*/
|
|
71
|
-
runInRequestScope<T>(callback: () => T | Promise<T>): Promise<T>;
|
|
72
|
-
/**
|
|
73
|
-
* Cleanup - call in afterAll
|
|
74
|
-
*/
|
|
75
|
-
close(): Promise<void>;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=testing-module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.d.ts","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAiB,MAAM,SAAS,CAAA;AAGhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,OAAO,CAAC,KAAK,CAA8B;gBAGxB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU;IAGlC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;IAInC;;OAEG;IACH,IAAI,IAAI,IAAI,cAAc,CAGzB;IAED;;;;;;;;;;;OAWG;IACH,IAAI,OAAO,IAAI,kBAAkB,CAEhC;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKhD;;OAEG;IACG,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { ROUTER_TOKENS } from 'stratal';
|
|
2
|
-
import { STORAGE_TOKENS } from 'stratal/storage';
|
|
3
|
-
import { TestHttpClient } from './http/test-http-client';
|
|
4
|
-
/**
|
|
5
|
-
* TestingModule
|
|
6
|
-
*
|
|
7
|
-
* Provides access to the test application, container, HTTP client, and utilities.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const module = await Test.createTestingModule({
|
|
12
|
-
* modules: [RegistrationModule],
|
|
13
|
-
* }).compile()
|
|
14
|
-
*
|
|
15
|
-
* // Make HTTP requests
|
|
16
|
-
* const response = await module.http
|
|
17
|
-
* .post('/api/v1/register')
|
|
18
|
-
* .withBody({ ... })
|
|
19
|
-
* .send()
|
|
20
|
-
*
|
|
21
|
-
* // Access services
|
|
22
|
-
* const service = module.get(REGISTRATION_TOKENS.RegistrationService)
|
|
23
|
-
*
|
|
24
|
-
* // Cleanup
|
|
25
|
-
* await module.close()
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export class TestingModule {
|
|
29
|
-
app;
|
|
30
|
-
env;
|
|
31
|
-
_http = null;
|
|
32
|
-
constructor(app, env) {
|
|
33
|
-
this.app = app;
|
|
34
|
-
this.env = env;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Resolve a service from the container
|
|
38
|
-
*/
|
|
39
|
-
get(token) {
|
|
40
|
-
return this.app.container.resolve(token);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get HTTP test client for making requests
|
|
44
|
-
*/
|
|
45
|
-
get http() {
|
|
46
|
-
this._http ??= new TestHttpClient(this);
|
|
47
|
-
return this._http;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get fake storage service for assertions
|
|
51
|
-
*
|
|
52
|
-
* Provides assertion helpers for testing file storage operations.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* module.storage.assertExists('path/to/file.pdf')
|
|
57
|
-
* module.storage.assertMissing('deleted/file.pdf')
|
|
58
|
-
* module.storage.clear() // Reset between tests
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
get storage() {
|
|
62
|
-
return this.get(STORAGE_TOKENS.StorageService);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get Application instance
|
|
66
|
-
*/
|
|
67
|
-
get application() {
|
|
68
|
-
return this.app;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get DI Container
|
|
72
|
-
*/
|
|
73
|
-
get container() {
|
|
74
|
-
return this.app.container;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Execute an HTTP request through RouterService
|
|
78
|
-
*
|
|
79
|
-
* This is the core method - calls RouterService.fetch() directly, no SELF.fetch()
|
|
80
|
-
*/
|
|
81
|
-
async fetch(request) {
|
|
82
|
-
const router = this.get(ROUTER_TOKENS.RouterService);
|
|
83
|
-
return router.fetch(request, this.env, this.app.ctx);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Run callback in request scope (for DB operations, service access)
|
|
87
|
-
*/
|
|
88
|
-
async runInRequestScope(callback) {
|
|
89
|
-
const mockContext = this.app.createMockRouterContext();
|
|
90
|
-
return this.app.container.runInRequestScope(mockContext, callback);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Cleanup - call in afterAll
|
|
94
|
-
*/
|
|
95
|
-
async close() {
|
|
96
|
-
await this.app.shutdown();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=testing-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testing-module.js","sourceRoot":"","sources":["../../src/core/testing-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,aAAa;IAIL;IACA;IAJX,KAAK,GAA0B,IAAI,CAAA;IAE3C,YACmB,GAAgB,EAChB,GAAe;QADf,QAAG,GAAH,GAAG,CAAa;QAChB,QAAG,GAAH,GAAG,CAAY;IAC9B,CAAC;IAEL;;OAEG;IACH,GAAG,CAAI,KAAwB;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,IAAI,CAAC,KAAK,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAqB,cAAc,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,OAAgB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAgB,aAAa,CAAC,aAAa,CAAC,CAAA;QACnE,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB,CAAI,QAA8B;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,CAAA;QACtD,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IAC3B,CAAC;CACF"}
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/errors/index.js
DELETED
package/dist/errors/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|