Skip to content

Commit 4db2ee9

Browse files
author
FrancescoMauto
committed
[DSC-2887] fix: test and lint
1 parent 1b958a3 commit 4db2ee9

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

src/app/app.metareducers.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { AppState } from './app.reducer';
21
import { universalMetaReducer } from './app.metareducers';
32
import { StoreActionTypes } from './store.actions';
43

@@ -13,13 +12,14 @@ describe('universalMetaReducer', () => {
1312

1413
describe('REHYDRATE', () => {
1514
it('should merge payload into state', () => {
16-
const state = { core: { existing: true } };
15+
const state = { otherProp: 'keep-me' };
1716
const payload = { core: { route: { queryParams: { f: ['x'] }, params: {} } } };
1817
const result = universalMetaReducer(mockReducer)(state, {
1918
type: StoreActionTypes.REHYDRATE,
2019
payload,
2120
});
22-
expect(result.core.existing).toBe(true);
21+
expect(result.otherProp).toBe('keep-me');
22+
expect(result.core.route).toEqual({ queryParams: {}, params: {} });
2323
});
2424

2525
it('should reset core.route to empty after rehydration', () => {
@@ -39,12 +39,12 @@ describe('universalMetaReducer', () => {
3939
type: StoreActionTypes.REHYDRATE,
4040
payload,
4141
});
42-
expect(result).toEqual(payload);
42+
expect(result.core.route).toEqual({ queryParams: {}, params: {} });
4343
});
4444

4545
it('should preserve other core properties when resetting route', () => {
46-
const state = { core: { route: {}, otherProp: 'keep-me' } };
47-
const payload = { core: { route: { queryParams: { x: '1' }, params: {} } } };
46+
const state = { core: { route: {} } };
47+
const payload = { core: { route: { queryParams: { x: '1' }, params: {} }, otherProp: 'keep-me' } };
4848
const result = universalMetaReducer(mockReducer)(state, {
4949
type: StoreActionTypes.REHYDRATE,
5050
payload,
@@ -61,4 +61,4 @@ describe('universalMetaReducer', () => {
6161
expect(result).toEqual(state);
6262
});
6363
});
64-
});
64+
});

src/app/app.metareducers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function universalMetaReducer(reducer) {
2121
state = Object.assign({}, state, action.payload);
2222
if (state.core) {
2323
state.core = Object.assign({}, state.core, {
24-
route: { queryParams: {}, params: {} }
24+
route: { queryParams: {}, params: {} },
2525
});
2626
}
2727
break;

src/app/core/services/route.reducer.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
SetQueryParameterAction,
1010
SetQueryParametersAction,
1111
} from './route.actions';
12-
import { routeReducer, RouteState } from './route.reducer';
12+
import {
13+
routeReducer,
14+
RouteState,
15+
} from './route.reducer';
1316

1417
describe('routeReducer', () => {
1518
const initialState: RouteState = {

src/app/item-page/cris-item-page-tab.resolver.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ export const crisItemPageTabResolver: ResolveFn<RemoteData<PaginatedList<CrisLay
5555
).pipe(
5656
getFirstCompletedRemoteData(),
5757
map((tabsRD: RemoteData<PaginatedList<CrisLayoutTab>>) => {
58-
if (tabsRD.hasSucceeded && tabsRD?.payload?.page?.length > 0) {
59-
// By splitting the url with uuid we can understand if the item is primary item page or a tab
60-
const urlWithoutQuery = state.url.split('?')[0];
61-
const urlSplit = urlWithoutQuery.split(route.params.id);
62-
const tabArguments = urlSplit[1]?.split('/');
63-
const givenTab = tabArguments?.[1];
64-
const itemPageRoute = getItemPageRoute(itemRD.payload);
58+
if (tabsRD.hasSucceeded && tabsRD?.payload?.page?.length > 0) {
59+
// By splitting the url with uuid we can understand if the item is primary item page or a tab
60+
const urlWithoutQuery = state.url.split('?')[0];
61+
const urlSplit = urlWithoutQuery.split(route.params.id);
62+
const tabArguments = urlSplit[1]?.split('/');
63+
const givenTab = tabArguments?.[1];
64+
const itemPageRoute = getItemPageRoute(itemRD.payload);
6565

66-
const isValidTab = !givenTab || tabsRD.payload.page.some((tab) => {
67-
const shortnameSplit = tab.shortname.split('::');
68-
const shortname = shortnameSplit[shortnameSplit.length - 1];
69-
return shortname === givenTab;
70-
});
66+
const isValidTab = !givenTab || tabsRD.payload.page.some((tab) => {
67+
const shortnameSplit = tab.shortname.split('::');
68+
const shortname = shortnameSplit[shortnameSplit.length - 1];
69+
return shortname === givenTab;
70+
});
7171

7272
const mainTab = tabsRD.payload.page.length === 1
7373
? tabsRD.payload.page[0]

0 commit comments

Comments
 (0)