@codefast/di-testing 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @codefast/di-testing
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#999](https://github.com/codefastlabs/codefast/pull/999) Requires `@codefast/di` 0.12, whose chains declare a binding's slot before its strategy; the test beds bind their mocks
|
|
8
|
+
and real collaborators in that order.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [#1005](https://github.com/codefastlabs/codefast/pull/1005) **Breaking for deep subpath imports only** — the root entry `@codefast/di` is unchanged. `src/` now follows three rules,
|
|
13
|
+
and the published subpaths follow `src/` with no exception: a directory names a family of two or more modules and a lone
|
|
14
|
+
module sits flat at its layer; a directory carries the topic and a file its role, so no file repeats its directory's
|
|
15
|
+
name; and the exports map is the source tree, so the `strip` that kept the introspection modules at flat specifiers is
|
|
16
|
+
gone.
|
|
17
|
+
|
|
18
|
+
Moves: the `MetadataReader` verification leaves `resolution/cache/class-introspector` for `metadata/verify` — it was the
|
|
19
|
+
one value import pointing up from `metadata/` into `resolution/`; the `RESOLUTION_DIAGNOSTICS` channel leaves `errors/`
|
|
20
|
+
for `introspection/diagnostics`; the fluent chain's contract leaves `core/binding` for `core/binding-builders`, and the
|
|
21
|
+
class implementing it is `container/binding-chain`; `effectiveBindingScope` folds into `core/binding`.
|
|
22
|
+
|
|
23
|
+
Renamed specifiers: `./errors/errors` → `./errors`; `./errors/diagnostics` → `./introspection/diagnostics`;
|
|
24
|
+
`./ambient/active-container` → `./ambient-container`; `./container/binding-builders` → `./container/binding-chain`;
|
|
25
|
+
`./core/binding-scope` → gone (`effectiveBindingScope` is in `./core/binding`); `./injection/resolve-options` →
|
|
26
|
+
`./injection/dependency-slot`;
|
|
27
|
+
`./metadata/{metadata-keys,metadata-types,metadata-reader-token,symbol-metadata-reader,verifying-metadata-reader}` →
|
|
28
|
+
`./metadata/{keys,types,reader-token,symbol-reader,verifying-reader}`; `./lifecycle/{lifecycle-manager,scope-manager}` →
|
|
29
|
+
`./lifecycle/{hooks,scopes}`; `./decorators/{lifecycle-decorators,decorator-metadata}` →
|
|
30
|
+
`./decorators/{lifecycle,metadata-record}`; `./resolution/path/resolution-path` → `./resolution/path`;
|
|
31
|
+
`./resolution/plan/{instantiation-plan,plan-codegen}` → `./resolution/plan/{compiler,codegen}`;
|
|
32
|
+
`./resolution/select/binding-select` → `./resolution/select/candidates`; `./resolution/cache/binding-lookup-cache` →
|
|
33
|
+
`./resolution/cache/lookup`; `./{inspector,explanation,dependency-graph,graph-adapters/*}` →
|
|
34
|
+
`./introspection/{inspector,explanation,dependency-graph,graph-adapters/*}`. New: `./core/binding-builders`,
|
|
35
|
+
`./metadata/verify`.
|
|
36
|
+
|
|
37
|
+
`@codefast/di-testing` follows the one specifier it imports, `metadata/verifying-reader`.
|
|
38
|
+
|
|
39
|
+
- Updated dependencies:
|
|
40
|
+
- @codefast/di@0.12.0
|
|
41
|
+
|
|
3
42
|
## 0.2.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -251,7 +251,7 @@ extending it, so setup failures can be caught separately from resolution failure
|
|
|
251
251
|
## Documentation
|
|
252
252
|
|
|
253
253
|
- [Rendered docs on codefastlabs.com](https://codefastlabs.com/docs/di-testing)
|
|
254
|
-
- [`@codefast/di`](../di/README.md) — the container this package builds on, including its `
|
|
254
|
+
- [`@codefast/di`](../di/README.md) — the container this package builds on, including its specification under `spec/`.
|
|
255
255
|
- [`CHANGELOG.md`](./CHANGELOG.md) — release history.
|
|
256
256
|
|
|
257
257
|
## Contributing
|
|
@@ -127,7 +127,7 @@ export function bindMocks(container, dependencies, overrides, mockFactory, expos
|
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
129
|
const bindConstant = (slot, value) => {
|
|
130
|
-
const builder = container.bind(slot.token)
|
|
130
|
+
const builder = container.bind(slot.token);
|
|
131
131
|
if (slot.name !== undefined) {
|
|
132
132
|
builder.whenNamed(slot.name);
|
|
133
133
|
}
|
|
@@ -136,6 +136,7 @@ export function bindMocks(container, dependencies, overrides, mockFactory, expos
|
|
|
136
136
|
builder.whenTagged(tag);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
builder.toConstantValue(value);
|
|
139
140
|
};
|
|
140
141
|
for (const slot of dependencies) {
|
|
141
142
|
const list = overrides.get(slot.token) ?? [];
|
|
@@ -167,8 +168,8 @@ export function bindMocks(container, dependencies, overrides, mockFactory, expos
|
|
|
167
168
|
for (const [index, value] of values.entries()) {
|
|
168
169
|
container
|
|
169
170
|
.bind(slot.token)
|
|
170
|
-
.
|
|
171
|
-
.
|
|
171
|
+
.whenNamed(`${ALL_ELEMENT_SLOT_PREFIX}${String(index)}`)
|
|
172
|
+
.toConstantValue(value);
|
|
172
173
|
}
|
|
173
174
|
record(slot.token, { criteria: override.criteria, value: values, kind: "all" });
|
|
174
175
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The override-recording core both test-bed builders extend. */
|
|
2
2
|
import { defaultMetadataReader } from "@codefast/di";
|
|
3
|
-
import { verifyingMetadataReader } from "@codefast/di/metadata/verifying-
|
|
3
|
+
import { verifyingMetadataReader } from "@codefast/di/metadata/verifying-reader";
|
|
4
4
|
import { criteriaEquals, normalizeCriteria } from "#discovery/mock-binder";
|
|
5
5
|
/**
|
|
6
6
|
* The shared builder core: records overrides, resolves the reader and mock factory, and owns the
|
|
@@ -61,13 +61,14 @@ export class SociableBuilder extends BedBuilder {
|
|
|
61
61
|
container.bind(realToken).to(realClass).singleton();
|
|
62
62
|
container.bind(realClass).toDynamic((context) => context.resolve(realToken));
|
|
63
63
|
for (const slot of slots) {
|
|
64
|
-
const builder = container.bind(realClass)
|
|
64
|
+
const builder = container.bind(realClass);
|
|
65
65
|
if (slot.name !== undefined) {
|
|
66
66
|
builder.whenNamed(slot.name);
|
|
67
67
|
}
|
|
68
68
|
for (const tag of slot.tags ?? []) {
|
|
69
69
|
builder.whenTagged(tag);
|
|
70
70
|
}
|
|
71
|
+
builder.toDynamic((context) => context.resolve(realToken));
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
// Sealed entries so mocks.get points at bed.exposed() instead of handing back a fake Mocked.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/di-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Solitary and sociable auto-mocking test beds for @codefast/di",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auto-mock",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"access": "public"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@codefast/di": ">=0.
|
|
103
|
+
"@codefast/di": ">=0.12.0"
|
|
104
104
|
},
|
|
105
105
|
"engines": {
|
|
106
106
|
"node": ">=24.0.0"
|