|
|
@@ -1,7 +1,13 @@
|
|
|
-import { itemReducer, makeExploreItemState, exploreReducer, makeInitialUpdateState } from './reducers';
|
|
|
-import { ExploreId, ExploreItemState, ExploreUrlState } from 'app/types/explore';
|
|
|
+import {
|
|
|
+ itemReducer,
|
|
|
+ makeExploreItemState,
|
|
|
+ exploreReducer,
|
|
|
+ makeInitialUpdateState,
|
|
|
+ initialExploreState,
|
|
|
+} from './reducers';
|
|
|
+import { ExploreId, ExploreItemState, ExploreUrlState, ExploreState } from 'app/types/explore';
|
|
|
import { reducerTester } from 'test/core/redux/reducerTester';
|
|
|
-import { scanStartAction, scanStopAction } from './actionTypes';
|
|
|
+import { scanStartAction, scanStopAction, splitOpenAction, splitCloseAction } from './actionTypes';
|
|
|
import { Reducer } from 'redux';
|
|
|
import { ActionOf } from 'app/core/redux/actionCreatorFactory';
|
|
|
import { updateLocation } from 'app/core/actions/location';
|
|
|
@@ -76,6 +82,82 @@ export const setup = (urlStateOverrides?: any) => {
|
|
|
};
|
|
|
|
|
|
describe('Explore reducer', () => {
|
|
|
+ describe('split view', () => {
|
|
|
+ it("should make right pane a duplicate of the given item's state on split open", () => {
|
|
|
+ const leftItemMock = {
|
|
|
+ containerWidth: 100,
|
|
|
+ } as ExploreItemState;
|
|
|
+
|
|
|
+ const initalState = {
|
|
|
+ split: null,
|
|
|
+ left: leftItemMock as ExploreItemState,
|
|
|
+ right: makeExploreItemState(),
|
|
|
+ } as ExploreState;
|
|
|
+
|
|
|
+ reducerTester()
|
|
|
+ .givenReducer(exploreReducer as Reducer<ExploreState, ActionOf<any>>, initalState)
|
|
|
+ .whenActionIsDispatched(splitOpenAction({ itemState: leftItemMock }))
|
|
|
+ .thenStateShouldEqual({
|
|
|
+ split: true,
|
|
|
+ left: leftItemMock,
|
|
|
+ right: leftItemMock,
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('split close', () => {
|
|
|
+ it('should keep right pane as left when left is closed', () => {
|
|
|
+ const leftItemMock = {
|
|
|
+ containerWidth: 100,
|
|
|
+ } as ExploreItemState;
|
|
|
+
|
|
|
+ const rightItemMock = {
|
|
|
+ containerWidth: 200,
|
|
|
+ } as ExploreItemState;
|
|
|
+
|
|
|
+ const initalState = {
|
|
|
+ split: null,
|
|
|
+ left: leftItemMock,
|
|
|
+ right: rightItemMock,
|
|
|
+ } as ExploreState;
|
|
|
+
|
|
|
+ // closing left item
|
|
|
+ reducerTester()
|
|
|
+ .givenReducer(exploreReducer as Reducer<ExploreState, ActionOf<any>>, initalState)
|
|
|
+ .whenActionIsDispatched(splitCloseAction({ itemId: ExploreId.left }))
|
|
|
+ .thenStateShouldEqual({
|
|
|
+ split: false,
|
|
|
+ left: rightItemMock,
|
|
|
+ right: initialExploreState.right,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ it('should reset right pane when it is closed ', () => {
|
|
|
+ const leftItemMock = {
|
|
|
+ containerWidth: 100,
|
|
|
+ } as ExploreItemState;
|
|
|
+
|
|
|
+ const rightItemMock = {
|
|
|
+ containerWidth: 200,
|
|
|
+ } as ExploreItemState;
|
|
|
+
|
|
|
+ const initalState = {
|
|
|
+ split: null,
|
|
|
+ left: leftItemMock,
|
|
|
+ right: rightItemMock,
|
|
|
+ } as ExploreState;
|
|
|
+
|
|
|
+ // closing left item
|
|
|
+ reducerTester()
|
|
|
+ .givenReducer(exploreReducer as Reducer<ExploreState, ActionOf<any>>, initalState)
|
|
|
+ .whenActionIsDispatched(splitCloseAction({ itemId: ExploreId.right }))
|
|
|
+ .thenStateShouldEqual({
|
|
|
+ split: false,
|
|
|
+ left: leftItemMock,
|
|
|
+ right: initialExploreState.right,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('when updateLocation is dispatched', () => {
|
|
|
describe('and payload does not contain a query', () => {
|
|
|
it('then it should just return state', () => {
|