@navios/core 1.1.0 → 2.0.0-alpha.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.
Files changed (237) hide show
  1. package/CHANGELOG.md +85 -13
  2. package/README.md +69 -220
  3. package/lib/async-context-BAdt7bno.d.mts +239 -0
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/async-context-RsWmy2Hi.d.cts +239 -0
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
  8. package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
  9. package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
  10. package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/execution-context-BVSmLkYp.d.cts +71 -0
  20. package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
  21. package/lib/execution-context-C5F9rojO.d.mts +71 -0
  22. package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
  23. package/lib/execution-context-token--cKS4cJv.cjs +270 -0
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +1672 -4426
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +842 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +842 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1559 -4221
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bz83ZnJ5.cjs +173 -0
  44. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  45. package/lib/module-options-CSqQUSTm.d.mts +51 -0
  46. package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
  47. package/lib/module-options-DSRBri4J.d.cts +51 -0
  48. package/lib/module-options-DSRBri4J.d.cts.map +1 -0
  49. package/lib/module-zPXwR2qp.mjs +138 -0
  50. package/lib/module-zPXwR2qp.mjs.map +1 -0
  51. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  52. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  53. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  54. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  55. package/lib/testing/index.cjs +74 -414
  56. package/lib/testing/index.cjs.map +1 -1
  57. package/lib/testing/index.d.cts +25 -385
  58. package/lib/testing/index.d.cts.map +1 -1
  59. package/lib/testing/index.d.mts +24 -385
  60. package/lib/testing/index.d.mts.map +1 -1
  61. package/lib/testing/index.mjs +72 -408
  62. package/lib/testing/index.mjs.map +1 -1
  63. package/lib/transport.cjs +36 -0
  64. package/lib/transport.d.cts +254 -0
  65. package/lib/transport.d.cts.map +1 -0
  66. package/lib/transport.d.mts +254 -0
  67. package/lib/transport.d.mts.map +1 -0
  68. package/lib/transport.mjs +6 -0
  69. package/package.json +37 -17
  70. package/docs/README.md +0 -316
  71. package/docs/adapters.md +0 -308
  72. package/docs/application-setup.md +0 -524
  73. package/docs/attributes.md +0 -689
  74. package/docs/controllers.md +0 -373
  75. package/docs/endpoints.md +0 -444
  76. package/docs/exceptions.md +0 -352
  77. package/docs/guards.md +0 -550
  78. package/docs/legacy-compat.md +0 -356
  79. package/docs/modules.md +0 -377
  80. package/docs/quick-start.md +0 -290
  81. package/docs/services.md +0 -427
  82. package/docs/testing.md +0 -827
  83. package/lib/index-3LcTrbxz.d.mts +0 -3804
  84. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  85. package/lib/index-B14SekVb.d.cts +0 -3804
  86. package/lib/index-B14SekVb.d.cts.map +0 -1
  87. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  88. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  89. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  90. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  91. package/lib/tokens-BEuBMGGX.cjs +0 -193
  92. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  93. package/lib/tokens-COyNGV1I.mjs +0 -97
  94. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  95. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  96. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  97. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  98. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  99. package/project.json +0 -66
  100. package/src/__tests__/attribute.factory.spec.mts +0 -300
  101. package/src/__tests__/config.service.spec.mts +0 -43
  102. package/src/__tests__/console-logger.service.spec.mts +0 -312
  103. package/src/__tests__/controller-resolver.spec.mts +0 -229
  104. package/src/__tests__/controller.spec.mts +0 -58
  105. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  106. package/src/__tests__/logger.service.spec.mts +0 -147
  107. package/src/__tests__/responders.spec.mts +0 -340
  108. package/src/__tests__/testing-module.spec.mts +0 -459
  109. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  110. package/src/attribute.factory.mts +0 -325
  111. package/src/config/config-service.interface.mts +0 -47
  112. package/src/config/config.provider.mts +0 -69
  113. package/src/config/config.service.mts +0 -176
  114. package/src/config/index.mts +0 -5
  115. package/src/config/types.mts +0 -58
  116. package/src/config/utils/helpers.mts +0 -23
  117. package/src/config/utils/index.mts +0 -1
  118. package/src/decorators/controller.decorator.mts +0 -81
  119. package/src/decorators/endpoint.decorator.mts +0 -181
  120. package/src/decorators/header.decorator.mts +0 -38
  121. package/src/decorators/http-code.decorator.mts +0 -38
  122. package/src/decorators/index.mts +0 -8
  123. package/src/decorators/module.decorator.mts +0 -106
  124. package/src/decorators/multipart.decorator.mts +0 -169
  125. package/src/decorators/stream.decorator.mts +0 -155
  126. package/src/decorators/use-guards.decorator.mts +0 -73
  127. package/src/exceptions/bad-request.exception.mts +0 -28
  128. package/src/exceptions/conflict.exception.mts +0 -31
  129. package/src/exceptions/forbidden.exception.mts +0 -30
  130. package/src/exceptions/http.exception.mts +0 -33
  131. package/src/exceptions/index.mts +0 -7
  132. package/src/exceptions/internal-server-error.exception.mts +0 -33
  133. package/src/exceptions/not-found.exception.mts +0 -33
  134. package/src/exceptions/unauthorized.exception.mts +0 -30
  135. package/src/factories/adapter.factory.mts +0 -20
  136. package/src/factories/endpoint-adapter.factory.mts +0 -21
  137. package/src/factories/http-adapter.factory.mts +0 -20
  138. package/src/factories/index.mts +0 -8
  139. package/src/factories/multipart-adapter.factory.mts +0 -21
  140. package/src/factories/reply.factory.mts +0 -21
  141. package/src/factories/request.factory.mts +0 -21
  142. package/src/factories/stream-adapter.factory.mts +0 -20
  143. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  144. package/src/index.mts +0 -16
  145. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  146. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  147. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  148. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  149. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  150. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  151. package/src/interfaces/adapter-environment.interface.mts +0 -74
  152. package/src/interfaces/can-activate.mts +0 -38
  153. package/src/interfaces/http-header.mts +0 -18
  154. package/src/interfaces/index.mts +0 -14
  155. package/src/interfaces/navios-module.mts +0 -28
  156. package/src/interfaces/plugin-context.mts +0 -104
  157. package/src/interfaces/plugin-stage.mts +0 -62
  158. package/src/interfaces/plugin.interface.mts +0 -119
  159. package/src/interfaces/staged-plugin.interface.mts +0 -209
  160. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  161. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  162. package/src/legacy-compat/attribute.factory.mts +0 -351
  163. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  164. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  165. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  167. package/src/legacy-compat/decorators/index.mts +0 -11
  168. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  169. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  170. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  171. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  172. package/src/legacy-compat/index.mts +0 -57
  173. package/src/logger/README.md +0 -3
  174. package/src/logger/console-logger.service.mts +0 -714
  175. package/src/logger/index.mts +0 -6
  176. package/src/logger/log-levels.mts +0 -21
  177. package/src/logger/logger-service.interface.mts +0 -42
  178. package/src/logger/logger.service.mts +0 -113
  179. package/src/logger/logger.tokens.mts +0 -44
  180. package/src/logger/utils/cli-colors.util.mts +0 -17
  181. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  182. package/src/logger/utils/index.mts +0 -5
  183. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  184. package/src/logger/utils/is-log-level.util.mts +0 -10
  185. package/src/logger/utils/shared.utils.mts +0 -51
  186. package/src/metadata/controller.metadata.mts +0 -79
  187. package/src/metadata/handler.metadata.mts +0 -80
  188. package/src/metadata/index.mts +0 -4
  189. package/src/metadata/module.metadata.mts +0 -116
  190. package/src/metadata/navios-managed.metadata.mts +0 -42
  191. package/src/navios.application.mts +0 -678
  192. package/src/navios.environment.mts +0 -42
  193. package/src/navios.factory.mts +0 -158
  194. package/src/responders/enums/framework-error.enum.mts +0 -38
  195. package/src/responders/enums/index.mts +0 -1
  196. package/src/responders/index.mts +0 -4
  197. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  198. package/src/responders/interfaces/error-response.interface.mts +0 -22
  199. package/src/responders/interfaces/index.mts +0 -3
  200. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  201. package/src/responders/services/error-response-producer.service.mts +0 -143
  202. package/src/responders/services/forbidden-responder.service.mts +0 -77
  203. package/src/responders/services/index.mts +0 -5
  204. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  205. package/src/responders/services/not-found-responder.service.mts +0 -76
  206. package/src/responders/services/validation-error-responder.service.mts +0 -78
  207. package/src/responders/tokens/index.mts +0 -1
  208. package/src/responders/tokens/responder.tokens.mts +0 -84
  209. package/src/services/abstract-handler-adapter.service.mts +0 -366
  210. package/src/services/guard-runner.service.mts +0 -152
  211. package/src/services/index.mts +0 -4
  212. package/src/services/instance-resolver.service.mts +0 -177
  213. package/src/services/module-loader.service.mts +0 -255
  214. package/src/stores/index.mts +0 -1
  215. package/src/stores/request-id.store.mts +0 -85
  216. package/src/testing/index.mts +0 -3
  217. package/src/testing/testing-module.mts +0 -393
  218. package/src/testing/unit-testing-module.mts +0 -298
  219. package/src/tokens/adapter.token.mts +0 -6
  220. package/src/tokens/endpoint-adapter.token.mts +0 -8
  221. package/src/tokens/execution-context.token.mts +0 -9
  222. package/src/tokens/http-adapter.token.mts +0 -8
  223. package/src/tokens/index.mts +0 -10
  224. package/src/tokens/multipart-adapter.token.mts +0 -8
  225. package/src/tokens/navios-options.token.mts +0 -6
  226. package/src/tokens/reply.token.mts +0 -3
  227. package/src/tokens/request.token.mts +0 -3
  228. package/src/tokens/stream-adapter.token.mts +0 -8
  229. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  230. package/src/utils/adapter-supports.util.mts +0 -47
  231. package/src/utils/define-plugin.mts +0 -251
  232. package/src/utils/index.mts +0 -2
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. package/vitest.config.mts +0 -15
@@ -1,459 +0,0 @@
1
- import { Injectable, InjectableScope, InjectionToken } from '@navios/di'
2
- import { afterEach, describe, expect, it } from 'vitest'
3
-
4
- import { Module } from '../decorators/module.decorator.mjs'
5
- import { createTestingModule, TestingModule } from '../testing/testing-module.mjs'
6
-
7
- describe('TestingModule', () => {
8
- let testingModule: TestingModule | null = null
9
-
10
- afterEach(async () => {
11
- if (testingModule) {
12
- await testingModule.close()
13
- testingModule = null
14
- }
15
- })
16
-
17
- describe('create', () => {
18
- it('should create a testing module with static create method', () => {
19
- @Module()
20
- class TestAppModule {}
21
-
22
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
23
-
24
- expect(testingModule).toBeInstanceOf(TestingModule)
25
- })
26
-
27
- it('should apply initial overrides from options', async () => {
28
- const TOKEN = InjectionToken.create<string>('test-token')
29
-
30
- @Module()
31
- class TestAppModule {}
32
-
33
- testingModule = TestingModule.create(TestAppModule, {
34
- adapter: [],
35
- overrides: [{ token: TOKEN, useValue: 'overridden-value' }],
36
- })
37
-
38
- await testingModule.compile()
39
- const value = await testingModule.get(TOKEN)
40
-
41
- expect(value).toBe('overridden-value')
42
- })
43
- })
44
-
45
- describe('createTestingModule (deprecated)', () => {
46
- it('should still work for backwards compatibility', () => {
47
- @Module()
48
- class TestAppModule {}
49
-
50
- testingModule = createTestingModule(TestAppModule, { adapter: [] })
51
-
52
- expect(testingModule).toBeInstanceOf(TestingModule)
53
- })
54
- })
55
-
56
- describe('compile', () => {
57
- it('should return this for chaining', async () => {
58
- @Module()
59
- class TestAppModule {}
60
-
61
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
62
- const result = await testingModule.compile()
63
-
64
- expect(result).toBe(testingModule)
65
- })
66
-
67
- it('should only compile once even when called multiple times', async () => {
68
- @Module()
69
- class TestAppModule {}
70
-
71
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
72
-
73
- const result1 = await testingModule.compile()
74
- const app1 = result1.getApp()
75
-
76
- const result2 = await testingModule.compile()
77
- const app2 = result2.getApp()
78
-
79
- expect(app1).toBe(app2)
80
- })
81
- })
82
-
83
- describe('init', () => {
84
- it('should return this for chaining', async () => {
85
- @Module()
86
- class TestAppModule {}
87
-
88
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
89
- const result = await testingModule.init()
90
-
91
- expect(result).toBe(testingModule)
92
- })
93
-
94
- it('should compile automatically if not already compiled', async () => {
95
- @Module()
96
- class TestAppModule {}
97
-
98
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
99
- await testingModule.init()
100
-
101
- expect(() => testingModule!.getApp()).not.toThrow()
102
- })
103
-
104
- it('should start a request scope after init', async () => {
105
- @Module()
106
- class TestAppModule {}
107
-
108
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
109
- await testingModule.init()
110
-
111
- expect(() => testingModule!.getScopedContainer()).not.toThrow()
112
- })
113
- })
114
-
115
- describe('getApp', () => {
116
- it('should throw if not compiled', () => {
117
- @Module()
118
- class TestAppModule {}
119
-
120
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
121
-
122
- expect(() => testingModule!.getApp()).toThrow(
123
- 'TestingModule not compiled. Call compile() or init() first.',
124
- )
125
- })
126
-
127
- it('should return the app after compile', async () => {
128
- @Module()
129
- class TestAppModule {}
130
-
131
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
132
- await testingModule.compile()
133
-
134
- const app = testingModule.getApp()
135
- expect(app).toBeDefined()
136
- })
137
- })
138
-
139
- describe('getScopedContainer', () => {
140
- it('should throw if init was not called', async () => {
141
- @Module()
142
- class TestAppModule {}
143
-
144
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
145
- await testingModule.compile()
146
-
147
- expect(() => testingModule!.getScopedContainer()).toThrow(
148
- 'No scoped container available. Call init() first.',
149
- )
150
- })
151
-
152
- it('should return scoped container after init', async () => {
153
- @Module()
154
- class TestAppModule {}
155
-
156
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
157
- await testingModule.init()
158
-
159
- const scopedContainer = testingModule.getScopedContainer()
160
- expect(scopedContainer).toBeDefined()
161
- })
162
- })
163
-
164
- describe('overrideProvider', () => {
165
- it('should override with useValue', async () => {
166
- @Injectable()
167
- class OriginalService {
168
- getValue() {
169
- return 'original'
170
- }
171
- }
172
-
173
- @Module()
174
- class TestAppModule {}
175
-
176
- const mockService = { getValue: () => 'mocked' }
177
-
178
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
179
- .overrideProvider(OriginalService)
180
- .useValue(mockService)
181
-
182
- await testingModule.compile()
183
- const service = await testingModule.get(OriginalService)
184
-
185
- expect(service.getValue()).toBe('mocked')
186
- })
187
-
188
- it('should override with useClass', async () => {
189
- @Injectable()
190
- class OriginalService {
191
- getValue() {
192
- return 'original'
193
- }
194
- }
195
-
196
- @Injectable()
197
- class MockService {
198
- getValue() {
199
- return 'mocked-class'
200
- }
201
- }
202
-
203
- @Module()
204
- class TestAppModule {}
205
-
206
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
207
- .overrideProvider(OriginalService)
208
- .useClass(MockService)
209
-
210
- await testingModule.compile()
211
- const service = await testingModule.get(OriginalService)
212
-
213
- expect(service.getValue()).toBe('mocked-class')
214
- })
215
-
216
- it('should support chaining multiple overrides', async () => {
217
- @Injectable()
218
- class ServiceA {
219
- getValue() {
220
- return 'a'
221
- }
222
- }
223
-
224
- @Injectable()
225
- class ServiceB {
226
- getValue() {
227
- return 'b'
228
- }
229
- }
230
-
231
- @Module()
232
- class TestAppModule {}
233
-
234
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
235
- .overrideProvider(ServiceA)
236
- .useValue({ getValue: () => 'mocked-a' })
237
- .overrideProvider(ServiceB)
238
- .useValue({ getValue: () => 'mocked-b' })
239
-
240
- await testingModule.compile()
241
-
242
- const serviceA = await testingModule.get(ServiceA)
243
- const serviceB = await testingModule.get(ServiceB)
244
-
245
- expect(serviceA.getValue()).toBe('mocked-a')
246
- expect(serviceB.getValue()).toBe('mocked-b')
247
- })
248
- })
249
-
250
- describe('get', () => {
251
- it('should resolve services after compile', async () => {
252
- @Injectable()
253
- class TestService {
254
- getValue() {
255
- return 'test'
256
- }
257
- }
258
-
259
- @Module()
260
- class TestAppModule {}
261
-
262
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
263
- await testingModule.compile()
264
-
265
- const service = await testingModule.get(TestService)
266
- expect(service.getValue()).toBe('test')
267
- })
268
-
269
- it('should resolve request-scoped services after init', async () => {
270
- @Injectable({ scope: InjectableScope.Request })
271
- class RequestScopedService {
272
- getValue() {
273
- return 'request-scoped'
274
- }
275
- }
276
-
277
- @Module()
278
- class TestAppModule {}
279
-
280
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
281
- await testingModule.init()
282
-
283
- const service = await testingModule.get(RequestScopedService)
284
- expect(service.getValue()).toBe('request-scoped')
285
- })
286
- })
287
-
288
- describe('close', () => {
289
- it('should clean up all resources', async () => {
290
- @Module()
291
- class TestAppModule {}
292
-
293
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
294
- await testingModule.init()
295
-
296
- await testingModule.close()
297
-
298
- // After close, getApp and getScopedContainer should throw
299
- expect(() => testingModule!.getApp()).toThrow()
300
- expect(() => testingModule!.getScopedContainer()).toThrow()
301
-
302
- testingModule = null // Prevent afterEach from calling close again
303
- })
304
- })
305
-
306
- describe('assertion helpers', () => {
307
- it('should expose expectResolved', async () => {
308
- @Injectable()
309
- class TestService {}
310
-
311
- @Module()
312
- class TestAppModule {}
313
-
314
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
315
- await testingModule.compile()
316
-
317
- await testingModule.get(TestService)
318
-
319
- expect(() => testingModule!.expectResolved(TestService)).not.toThrow()
320
- })
321
-
322
- it('should expose expectNotResolved', async () => {
323
- @Injectable()
324
- class TestService {}
325
-
326
- @Module()
327
- class TestAppModule {}
328
-
329
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
330
- await testingModule.compile()
331
-
332
- expect(() => testingModule!.expectNotResolved(TestService)).not.toThrow()
333
- })
334
-
335
- it('should expose expectSingleton', async () => {
336
- @Injectable({ scope: InjectableScope.Singleton })
337
- class SingletonService {}
338
-
339
- @Module()
340
- class TestAppModule {}
341
-
342
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
343
- await testingModule.compile()
344
-
345
- expect(() => testingModule!.expectSingleton(SingletonService)).not.toThrow()
346
- })
347
-
348
- it('should expose expectTransient', async () => {
349
- @Injectable({ scope: InjectableScope.Transient })
350
- class TransientService {}
351
-
352
- @Module()
353
- class TestAppModule {}
354
-
355
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
356
- await testingModule.compile()
357
-
358
- expect(() => testingModule!.expectTransient(TransientService)).not.toThrow()
359
- })
360
-
361
- it('should expose expectRequestScoped', async () => {
362
- @Injectable({ scope: InjectableScope.Request })
363
- class RequestService {}
364
-
365
- @Module()
366
- class TestAppModule {}
367
-
368
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
369
- await testingModule.compile()
370
-
371
- expect(() => testingModule!.expectRequestScoped(RequestService)).not.toThrow()
372
- })
373
- })
374
-
375
- describe('method call tracking', () => {
376
- it('should record and assert method calls', async () => {
377
- @Injectable()
378
- class MockService {
379
- doSomething(arg: string) {
380
- return arg.toUpperCase()
381
- }
382
- }
383
-
384
- @Module()
385
- class TestAppModule {}
386
-
387
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
388
- await testingModule.compile()
389
-
390
- // Manually record a method call (typically done in mock implementations)
391
- testingModule.recordMethodCall(MockService, 'doSomething', ['test'], 'TEST')
392
-
393
- expect(() => testingModule!.expectCalled(MockService, 'doSomething')).not.toThrow()
394
- expect(() =>
395
- testingModule!.expectCalledWith(MockService, 'doSomething', ['test']),
396
- ).not.toThrow()
397
- expect(() =>
398
- testingModule!.expectCallCount(MockService, 'doSomething', 1),
399
- ).not.toThrow()
400
- })
401
-
402
- it('should get method calls for custom assertions', async () => {
403
- @Injectable()
404
- class MockService {}
405
-
406
- @Module()
407
- class TestAppModule {}
408
-
409
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
410
- await testingModule.compile()
411
-
412
- testingModule.recordMethodCall(MockService, 'method1', ['a'])
413
- testingModule.recordMethodCall(MockService, 'method2', ['b', 'c'])
414
-
415
- const calls = testingModule.getMethodCalls(MockService)
416
-
417
- expect(calls).toHaveLength(2)
418
- expect(calls[0].method).toBe('method1')
419
- expect(calls[1].method).toBe('method2')
420
- })
421
- })
422
-
423
- describe('dependency graph', () => {
424
- it('should expose getDependencyGraph', async () => {
425
- @Injectable()
426
- class TestService {}
427
-
428
- @Module()
429
- class TestAppModule {}
430
-
431
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
432
- await testingModule.compile()
433
-
434
- await testingModule.get(TestService)
435
-
436
- const graph = testingModule.getDependencyGraph()
437
-
438
- expect(graph).toHaveProperty('nodes')
439
- expect(graph).toHaveProperty('rootTokens')
440
- })
441
-
442
- it('should expose getSimplifiedDependencyGraph', async () => {
443
- @Injectable()
444
- class TestService {}
445
-
446
- @Module()
447
- class TestAppModule {}
448
-
449
- testingModule = TestingModule.create(TestAppModule, { adapter: [] })
450
- await testingModule.compile()
451
-
452
- await testingModule.get(TestService)
453
-
454
- const graph = testingModule.getSimplifiedDependencyGraph()
455
-
456
- expect(typeof graph).toBe('object')
457
- })
458
- })
459
- })