2019-01-23 08:05:54 -06:00
|
|
|
import { itemReducer, makeExploreItemState } from './reducers';
|
2019-02-04 00:47:10 -06:00
|
|
|
import { ExploreId, ExploreItemState } from 'app/types/explore';
|
|
|
|
import { reducerTester } from 'test/core/redux/reducerTester';
|
|
|
|
import { scanStartAction, scanStopAction } from './actionTypes';
|
|
|
|
import { Reducer } from 'redux';
|
|
|
|
import { ActionOf } from 'app/core/redux/actionCreatorFactory';
|
2019-01-23 08:05:54 -06:00
|
|
|
|
|
|
|
describe('Explore item reducer', () => {
|
|
|
|
describe('scanning', () => {
|
|
|
|
test('should start scanning', () => {
|
2019-02-04 00:47:10 -06:00
|
|
|
const scanner = jest.fn();
|
|
|
|
const initalState = {
|
|
|
|
...makeExploreItemState(),
|
|
|
|
scanning: false,
|
|
|
|
scanner: undefined,
|
2019-01-23 08:05:54 -06:00
|
|
|
};
|
2019-02-04 00:47:10 -06:00
|
|
|
|
|
|
|
reducerTester()
|
|
|
|
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
|
|
|
.whenActionIsDispatched(scanStartAction({ exploreId: ExploreId.left, scanner }))
|
|
|
|
.thenStateShouldEqual({
|
|
|
|
...makeExploreItemState(),
|
|
|
|
scanning: true,
|
|
|
|
scanner,
|
|
|
|
});
|
2019-01-23 08:05:54 -06:00
|
|
|
});
|
|
|
|
test('should stop scanning', () => {
|
2019-02-04 00:47:10 -06:00
|
|
|
const scanner = jest.fn();
|
|
|
|
const initalState = {
|
|
|
|
...makeExploreItemState(),
|
|
|
|
scanning: true,
|
|
|
|
scanner,
|
|
|
|
scanRange: {},
|
2019-01-23 08:05:54 -06:00
|
|
|
};
|
2019-02-04 00:47:10 -06:00
|
|
|
|
|
|
|
reducerTester()
|
|
|
|
.givenReducer(itemReducer as Reducer<ExploreItemState, ActionOf<any>>, initalState)
|
|
|
|
.whenActionIsDispatched(scanStopAction({ exploreId: ExploreId.left }))
|
|
|
|
.thenStateShouldEqual({
|
|
|
|
...makeExploreItemState(),
|
|
|
|
scanning: false,
|
|
|
|
scanner: undefined,
|
|
|
|
scanRange: undefined,
|
|
|
|
});
|
2019-01-23 08:05:54 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|