You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to test your component with immutable data structures, you can use the `react-elmish/testing/immutable` module. This module provides the same functions as the normal testing module.
529
+
If you want to test your component with immutable data structures, you can use the `react-elmish/testing/immutable` module. This module provides the same functions as the normal [testing](#testing-1) module.
529
530
530
531
## Setup
531
532
@@ -990,6 +991,7 @@ To test your **update** handler you can use some helper functions in `react-elmi
990
991
| `initAndExecCmd` | Calls the `init` function with the provided props and executes the returned commands. |
991
992
| `getUpdateFn` | Returns an `update` function for your update map object. |
992
993
| `getUpdateAndExecCmdFn` | Returns an `update` function for your update map object, which immediately executes the command. |
994
+
| `getConsecutiveUpdateFn` | Returns an `update` function for your update map object, which runs all consecutive commands until only the model gets updated or nothing happens. |
993
995
| `getCreateUpdateArgs` | Creates a factory function to create a message, a model, and props in a test. |
994
996
| `createUpdateArgsFactory` | This is an alternative for `getCreateUpdateArgs`. Creates a factory function to create a message, a model, and props in a test. |
995
997
| `execCmd` | Executes the provided command and returns an array of all messages. |
If you want to test multiple `update` functions which are called in a row, you can use the `getConsecutiveUpdateFn` function. This function returns an `update` function that runs all consecutive commands until only the model gets updated or nothing happens.
1093
+
1094
+
You may have something like this in your `update` map:
1095
+
1096
+
"load message -> load function -> loaded message -> filter message -> filter function -> filtered message"
1097
+
1098
+
Then the `consecutiveUpdateFn` will execute all these commands in a row and return the final model after all commands have been executed.
expect(newModel).toStrictEqual({ /* what you expect in the model */ });
1116
+
});
1117
+
```
1118
+
1088
1119
### Testing subscriptions
1089
1120
1090
1121
It is almost the same as testing the `update` function. You can use the `getCreateModelAndProps` function to create a factory for the model and the props. Then use `execSubscription` to execute the subscriptions:
0 commit comments