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
Copy file name to clipboardExpand all lines: packages/router-component-store/README.md
+147Lines changed: 147 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,3 +208,150 @@ export type StrictRouteParams = {
208
208
readonly [key:string]:string|undefined;
209
209
};
210
210
```
211
+
212
+
## Testing
213
+
214
+
Router Component Store provides testing utilities to make it easy to test components and services that depend on `RouterStore`.
215
+
216
+
### TestingRouterStore
217
+
218
+
`TestingRouterStore` is a testing implementation of the `RouterStore` interface that uses stubbed observables. This allows you to easily control router state in your tests without needing to set up complex routing configurations.
|`setFragment(fragment: string \| null)`| Set the URL fragment |
317
+
|`setTitle(title: string \| undefined)`| Set the resolved route title |
318
+
|`setRouteParam(param: string, value: string \| undefined)`| Set a single route parameter |
319
+
|`setRouteParams(params: StrictRouteParams)`| Set all route parameters |
320
+
|`setQueryParam(param: string, value: string \| readonly string[] \| undefined)`| Set a single query parameter |
321
+
|`setQueryParams(params: StrictQueryParams)`| Set all query parameters |
322
+
|`setRouteDataParam(key: string, value: unknown)`| Set a single route data value |
323
+
|`setRouteData(data: StrictRouteData)`| Set all route data |
324
+
|`setCurrentRoute(route: MinimalActivatedRouteSnapshot)`| Set the complete current route |
325
+
|`reset()`| Reset all values to their defaults |
326
+
327
+
#### Integration with RouterTestingModule
328
+
329
+
While `TestingRouterStore` is great for isolated unit tests, you might sometimes want to test the full routing behavior. You can still use `RouterTestingModule` with the actual `RouterStore` implementations:
0 commit comments