bunja 4.0.0-alpha.2 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -406,3 +406,42 @@ const myBunja = bunja(() => {
|
|
|
406
406
|
return { fooData, barData };
|
|
407
407
|
});
|
|
408
408
|
```
|
|
409
|
+
|
|
410
|
+
### Overriding Bunja for tests
|
|
411
|
+
|
|
412
|
+
You can use store overrides to test bunjas with replacement dependencies
|
|
413
|
+
while keeping their definitions and dependency targets static.
|
|
414
|
+
Pass `override(target, init)` descriptors to `createBunjaStore({ overrides })`;
|
|
415
|
+
consumers keep calling `bunja.use(target)` and receive the replacement in that
|
|
416
|
+
store.
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
import { strictEqual } from "node:assert";
|
|
420
|
+
import { bunja, createBunjaStore, override } from "bunja";
|
|
421
|
+
|
|
422
|
+
const greetingBunja = bunja(() => ({
|
|
423
|
+
greet: (name: string) => `Hello, ${name}!`,
|
|
424
|
+
}));
|
|
425
|
+
const welcomeBunja = bunja(() => {
|
|
426
|
+
const greeting = bunja.use(greetingBunja);
|
|
427
|
+
return greeting.greet("Bunja");
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const fakeGreeting = { greet: (name: string) => `Hi, ${name}!` };
|
|
431
|
+
const store = createBunjaStore({
|
|
432
|
+
overrides: [override(greetingBunja, () => fakeGreeting)],
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
try {
|
|
436
|
+
const welcome = store.get(welcomeBunja, () => {
|
|
437
|
+
throw new Error("No scopes are expected in this test.");
|
|
438
|
+
});
|
|
439
|
+
strictEqual(welcome.value, "Hi, Bunja!");
|
|
440
|
+
} finally {
|
|
441
|
+
store.dispose();
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Overrides are fixed when the store is created. The initializer must match the
|
|
446
|
+
target’s value and seed types. To supply a fixed value, return it from an
|
|
447
|
+
initializer: `override(target, () => fakeValue)`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunja",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.3",
|
|
5
5
|
"description": "State Lifetime Manager",
|
|
6
6
|
"main": "./dist/bunja.js",
|
|
7
7
|
"types": "dist/bunja.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/react-test-renderer": "^19.3.0",
|
|
46
46
|
"react": "^19",
|
|
47
47
|
"react-test-renderer": "^19.3.1",
|
|
48
|
-
"solid-js": "2.0.
|
|
48
|
+
"solid-js": "2.0.4",
|
|
49
49
|
"tsdown": "0.23.3",
|
|
50
50
|
"typescript": "^5.6.3",
|
|
51
51
|
"tsx": "^4.20.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@types/react": "*",
|
|
56
56
|
"react": ">=18",
|
|
57
|
-
"solid-js": "^1 || ^2
|
|
57
|
+
"solid-js": "^1 || ^2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@types/react": {
|