changeNextPageContext(pageContext: PageContext) {
this.store.dispatch(new RoutingActions.ChangeNextPageContext(pageContext));
}
Copy the code
As can be seen from the implementation code, the Page Context of all SAP Spartacus routing pages, namely the combination of id and Type fields, is maintained in the NGRX Store. The Page context is inserted, via the Store’s Dispatch method.
So the method of writing unit tests is: when the service changeNextPageContext is invoked, monitoring store dispatch method is invoked, and the incoming parameters for RoutingActions. ChangeNextPageContext.
More of Jerry’s original articles can be found in “Wang Zixi” :