Skip to content

Commit

Permalink
feat(router-store) Add base router selectors
Browse files Browse the repository at this point in the history
- correct unit tests
  • Loading branch information
jasonhodges authored and Jason Hodges committed May 24, 2019
1 parent 7c37ccd commit 0f6a2fd
Show file tree
Hide file tree
Showing 3 changed files with 1,305 additions and 48 deletions.
52 changes: 5 additions & 47 deletions modules/router-store/spec/router_selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,70 +118,28 @@ describe('Router State Selectors', () => {
it('should create a selector for selecting the query params', () => {
const result = selectors.selectQueryParams(state);

expect(result.queryParams).toEqual(
expect(result).toEqual(
state.router.state.root.firstChild.firstChild.queryParams
);
});
it('should create a selector for selecting the route params', () => {
const result = selectors.selectRouteParams(state);

expect(result.params).toEqual(
expect(result).toEqual(
state.router.state.root.firstChild.firstChild.params
);
});
it('should create a selector for selecting the route data', () => {
const result = selectors.selectRouteData(state);

expect(result.data).toEqual(
expect(result).toEqual(
state.router.state.root.firstChild.firstChild.data
);
});
it('should create a selector for selecting the url', () => {
const url = selectors.selectUrl(state);
const result = selectors.selectUrl(state);

expect(url).toEqual(state.router.state.url);
expect(result).toEqual(state.router.state.url);
});
});
// xdescribe('Uncomposed Selectors', () => {
// // interface State {
// // router: RouterReducerState<any>;
// // }
// type State = RouterReducerState<any>;
// let selectors: RouterStateSelectors<any, RouterReducerState<any>>;
// let state: State;
//
// beforeEach(() => {
// // state = {
// // router: mockData,
// // };
// state = mockData;
// selectors = getSelectors();
// });
// it('should create a selector for selecting the query params', () => {
// const result = selectors.selectQueryParams(state);
//
// expect(result.queryParams).toEqual(
// state.root.firstChild.firstChild.queryParams
// );
// });
// it('should create a selector for selecting the route params', () => {
// const result = selectors.selectRouteParams(state);
//
// expect(result.params).toEqual(
// state.router.state.root.firstChild.firstChild.params
// );
// });
// it('should create a selector for selecting the route data', () => {
// const result = selectors.selectRouteData(state);
//
// expect(result.data).toEqual(
// state.router.state.root.firstChild.firstChild.data
// );
// });
// it('should create a selector for selecting the url', () => {
// const url = selectors.selectUrl(state);
//
// expect(url).toEqual(state.router.state.url);
// });
// });
});
2 changes: 1 addition & 1 deletion modules/router-store/src/router_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getSelectors<V>(
selectState: (state: V) => RouterReducerState<any>
): RouterStateSelectors<any, V>;
export function getSelectors<T>(
selectState = (state: any) => state.state // is this what you are thinking for providing default selectState?
selectState = (state: any) => state.state
): RouterStateSelectors<T, any> {
const router = (state: any) => state;
const selectRouterState = createSelector(
Expand Down
Loading

0 comments on commit 0f6a2fd

Please sign in to comment.