@fictjs/testing-library 0.14.0 → 0.16.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/README.md +7 -6
- package/dist/index.cjs +10 -9
- package/dist/index.js +10 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -142,6 +142,7 @@ rerender([20])
|
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
> **Note:** `rerender()` disposes the previous root and creates a new one. Hook state does not persist across rerenders.
|
|
145
|
+
> Disposal runs effect cleanups from the previous root before mounting the new hook instance.
|
|
145
146
|
|
|
146
147
|
### 4. Testing Effects
|
|
147
148
|
|
|
@@ -266,12 +267,12 @@ function renderHook<Result, Props extends unknown[] = []>(
|
|
|
266
267
|
|
|
267
268
|
**Returns:**
|
|
268
269
|
|
|
269
|
-
| Property | Type | Description
|
|
270
|
-
| ------------------ | ------------------------- |
|
|
271
|
-
| `result` | `{ current: Result }` | Container holding the hook's return value
|
|
272
|
-
| `rerender(props?)` | `(props?: Props) => void` |
|
|
273
|
-
| `cleanup()` | `() => void` | Clean up the hook
|
|
274
|
-
| `unmount()` | `() => void` | Alias for cleanup
|
|
270
|
+
| Property | Type | Description |
|
|
271
|
+
| ------------------ | ------------------------- | ------------------------------------------------ |
|
|
272
|
+
| `result` | `{ current: Result }` | Container holding the hook's return value |
|
|
273
|
+
| `rerender(props?)` | `(props?: Props) => void` | Remount with new props (previous state disposed) |
|
|
274
|
+
| `cleanup()` | `() => void` | Clean up the hook |
|
|
275
|
+
| `unmount()` | `() => void` | Alias for cleanup |
|
|
275
276
|
|
|
276
277
|
**Example:**
|
|
277
278
|
|
package/dist/index.cjs
CHANGED
|
@@ -173,18 +173,19 @@ function renderHook(hookFn, options = {}) {
|
|
|
173
173
|
let hookResult;
|
|
174
174
|
if (wrapper) {
|
|
175
175
|
const Wrapper = wrapper;
|
|
176
|
+
const HookRunner = () => {
|
|
177
|
+
(0, import_internal.__fictPushContext)();
|
|
178
|
+
try {
|
|
179
|
+
hookResult = hookFn(...currentProps);
|
|
180
|
+
} finally {
|
|
181
|
+
(0, import_internal.__fictPopContext)();
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
};
|
|
176
185
|
(0, import_runtime.createElement)({
|
|
177
186
|
type: Wrapper,
|
|
178
187
|
props: {
|
|
179
|
-
children:
|
|
180
|
-
(0, import_internal.__fictPushContext)();
|
|
181
|
-
try {
|
|
182
|
-
hookResult = hookFn(...currentProps);
|
|
183
|
-
} finally {
|
|
184
|
-
(0, import_internal.__fictPopContext)();
|
|
185
|
-
}
|
|
186
|
-
return null;
|
|
187
|
-
})()
|
|
188
|
+
children: { type: HookRunner, props: {} }
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
191
|
} else {
|
package/dist/index.js
CHANGED
|
@@ -144,18 +144,19 @@ function renderHook(hookFn, options = {}) {
|
|
|
144
144
|
let hookResult;
|
|
145
145
|
if (wrapper) {
|
|
146
146
|
const Wrapper = wrapper;
|
|
147
|
+
const HookRunner = () => {
|
|
148
|
+
__fictPushContext();
|
|
149
|
+
try {
|
|
150
|
+
hookResult = hookFn(...currentProps);
|
|
151
|
+
} finally {
|
|
152
|
+
__fictPopContext();
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
};
|
|
147
156
|
createElement({
|
|
148
157
|
type: Wrapper,
|
|
149
158
|
props: {
|
|
150
|
-
children:
|
|
151
|
-
__fictPushContext();
|
|
152
|
-
try {
|
|
153
|
-
hookResult = hookFn(...currentProps);
|
|
154
|
-
} finally {
|
|
155
|
-
__fictPopContext();
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
})()
|
|
159
|
+
children: { type: HookRunner, props: {} }
|
|
159
160
|
}
|
|
160
161
|
});
|
|
161
162
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fictjs/testing-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Testing utilities for Fict components, built on @testing-library/dom",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"jsdom": "^28.1.0",
|
|
38
38
|
"tsup": "^8.5.1",
|
|
39
39
|
"vitest": "^4.0.18",
|
|
40
|
-
"@fictjs/compiler": "0.
|
|
41
|
-
"@fictjs/runtime": "0.
|
|
42
|
-
"@fictjs/vite-plugin": "0.
|
|
40
|
+
"@fictjs/compiler": "0.16.0",
|
|
41
|
+
"@fictjs/runtime": "0.16.0",
|
|
42
|
+
"@fictjs/vite-plugin": "0.16.0"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"fict",
|