Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

update tests

Jason Kent2cfa2a302b25
diff --git a/web/js/modules/compare/actions.test.js b/web/js/modules/compare/actions.test.js
index 3fef8aee8..921c83152 100644
--- a/web/js/modules/compare/actions.test.js
+++ b/web/js/modules/compare/actions.test.js
@@ -9,7 +9,7 @@ import {
} from './actions';
import { INIT_SECOND_LAYER_GROUP } from '../layers/constants';
import fixtures from '../../fixtures';
-import { INIT_SECOND_DATE } from '../date/constants';
+import { INIT_SECOND_DATE, CLEAR_PRELOAD } from '../date/constants';
const middlewares = [thunk];
const state = fixtures.getState();
@@ -30,10 +30,15 @@ test('toggleCompareOnOff dispactches two actions', () => {
test(
`toggleActiveCompareState returns ${CONSTANTS.CHANGE_STATE} action type`,
() => {
- const expectedAction = {
- type: CONSTANTS.CHANGE_STATE,
- };
- expect(toggleActiveCompareState()).toEqual(expectedAction);
+ const mockStore = configureMockStore(middlewares);
+ const store = mockStore(state);
+ store.dispatch(toggleActiveCompareState());
+ const firstResponse = store.getActions()[0];
+ const secondResponse = store.getActions()[1];
+ const expectedFirst = { type: CLEAR_PRELOAD };
+ const expectedSecond = { type: CONSTANTS.CHANGE_STATE };
+ expect(firstResponse).toEqual(expectedFirst);
+ expect(secondResponse).toEqual(expectedSecond);
},
);
test(
diff --git a/web/js/modules/date/actions.test.js b/web/js/modules/date/actions.test.js
index 02089808f..ceffe3059 100644
--- a/web/js/modules/date/actions.test.js
+++ b/web/js/modules/date/actions.test.js
@@ -13,6 +13,7 @@ import {
CHANGE_INTERVAL,
SELECT_DATE,
UPDATE_APP_NOW,
+ CLEAR_PRELOAD,
} from './constants';
import fixtures from '../../fixtures';
import { addLayer, getLayers } from '../layers/selectors';
@@ -57,98 +58,138 @@ const delta = 5;
const interval = 3;
describe('Date timescale changes', () => {
- test(`changeTimeScale action returns ${CHANGE_TIME_SCALE}as type and ${
- interval} as value`, () => {
- const expectedAction = {
- type: CHANGE_TIME_SCALE,
- value: interval,
- };
- expect(changeTimeScale(interval)).toEqual(expectedAction);
- });
+ test(`changeTimeScale action returns ${CHANGE_TIME_SCALE} as type and ${interval} as value`,
+ () => {
+ const expectedAction = {
+ type: CHANGE_TIME_SCALE,
+ value: interval,
+ };
+ expect(changeTimeScale(interval)).toEqual(expectedAction);
+ });
- test(`updateAppNow action returns ${UPDATE_APP_NOW}as type and ${
- mockDate} as value`, () => {
- const expectedAction = {
- type: UPDATE_APP_NOW,
- value: mockDate,
- };
- expect(updateAppNow(mockDate)).toEqual(expectedAction);
- });
+ test(`updateAppNow action returns ${UPDATE_APP_NOW}as type and ${mockDate} as value`,
+ () => {
+ const expectedAction = {
+ type: UPDATE_APP_NOW,
+ value: mockDate,
+ };
+ expect(updateAppNow(mockDate)).toEqual(expectedAction);
+ });
- test(`selectDate action returns ${SELECT_DATE}as type and selected `
- + `as activeString and ${mockDate} as value`, () => {
- const expectedAction = {
- type: SELECT_DATE,
- activeString: 'selected',
- value: mockDate,
- };
- let layers = addLayer('terra-cr', {}, [], config.layers, 0);
- layers = addMockLayer('aqua-cr', layers);
- const store = mockStore({
- date: {},
- compare: {
- isCompareA: true,
- activeString: 'active',
- },
- layers: {
- active: {
- layers,
+ test(`selectDate action returns ${SELECT_DATE}as type and selected as activeString and ${mockDate} as value`,
+ () => {
+ const expectedFirst = {
+ type: CLEAR_PRELOAD,
+ };
+ const expectedSecond = {
+ type: SELECT_DATE,
+ activeString: 'selected',
+ value: mockDate,
+ lastArrowDirection: 'left',
+ };
+ let layers = addLayer('terra-cr', {}, [], config.layers, 0);
+ layers = addMockLayer('aqua-cr', layers);
+ const store = mockStore({
+ date: {},
+ compare: {
+ isCompareA: true,
+ activeString: 'active',
},
- },
- proj: {
- id: 'geographic',
- },
+ layers: {
+ active: {
+ layers,
+ },
+ },
+ proj: {
+ id: 'geographic',
+ },
+ });
+ store.dispatch(selectDate(mockDate));
+ expect(store.getActions()[0]).toEqual(expectedFirst);
+ expect(store.getActions()[1]).toEqual(expectedSecond);
});
- store.dispatch(selectDate(mockDate));
- expect(store.getActions()[0]).toEqual(expectedAction);
- });
- test(`selectDate action returns ${SELECT_DATE}as type and selectedB `
- + `as activeString and ${mockDate} as value`, () => {
- const expectedAction = {
- type: SELECT_DATE,
- activeString: 'selectedB',
- value: mockDate,
- };
- let layers = addLayer('terra-cr', {}, [], config.layers, 0);
- layers = addMockLayer('aqua-cr', layers);
- const store = mockStore({
- date: {},
- compare: {
- isCompareA: false,
- activeString: 'activeB',
- },
- layers: {
- activeB: {
- layers,
+ test(`selectDate action returns ${SELECT_DATE}as type and selectedB as activeString and ${mockDate} as value`,
+ () => {
+ const expectedFirst = {
+ type: CLEAR_PRELOAD,
+ };
+ const expectedSecond = {
+ type: SELECT_DATE,
+ activeString: 'selectedB',
+ value: mockDate,
+ lastArrowDirection: 'left',
+ };
+ let layers = addLayer('terra-cr', {}, [], config.layers, 0);
+ layers = addMockLayer('aqua-cr', layers);
+ const store = mockStore({
+ date: {},
+ compare: {
+ isCompareA: false,
+ activeString: 'activeB',
},
- },
- proj: {
- id: 'geographic',
- },
+ layers: {
+ activeB: {
+ layers,
+ },
+ },
+ proj: {
+ id: 'geographic',
+ },
+ });
+ store.dispatch(selectDate(mockDate));
+ expect(store.getActions()[0]).toEqual(expectedFirst);
+ expect(store.getActions()[1]).toEqual(expectedSecond);
});
- store.dispatch(selectDate(mockDate));
- expect(store.getActions()[0]).toEqual(expectedAction);
- });
- test(`changeCustomInterval action returns ${CHANGE_CUSTOM_INTERVAL} as type and ${
- customInterval} as value and ${delta} as delta`, () => {
- const expectedAction = {
- type: CHANGE_CUSTOM_INTERVAL,
- value: customInterval,
- delta,
- };
- expect(changeCustomInterval(delta, customInterval)).toEqual(expectedAction);
- });
+ test(`changeCustomInterval action returns ${CHANGE_CUSTOM_INTERVAL} as type and ${customInterval} as value and ${delta} as delta`,
+ () => {
+ const store = mockStore({
+ date: {},
+ compare: {
+ isCompareA: false,
+ activeString: 'activeB',
+ },
+ proj: {
+ id: 'geographic',
+ },
+ });
+ const expectedFirst = {
+ type: CLEAR_PRELOAD,
+ };
+ const expectedSecond = {
+ type: CHANGE_CUSTOM_INTERVAL,
+ value: customInterval,
+ delta,
+ };
+ store.dispatch(changeCustomInterval(delta, customInterval));
+ expect(store.getActions()[0]).toEqual(expectedFirst);
+ expect(store.getActions()[1]).toEqual(expectedSecond);
+ });
- test(`selectInterval action returns ${CHANGE_INTERVAL} as type and ${
- interval} as value and ${delta} as delta and true as customSelected`, () => {
- const expectedAction = {
- type: CHANGE_INTERVAL,
- value: interval,
- delta,
- customSelected: true,
- };
- expect(selectInterval(delta, interval, true)).toEqual(expectedAction);
- });
+ test(`selectInterval action returns ${CHANGE_INTERVAL} as type and ${interval} as value and ${delta} as delta and true as customSelected`,
+ () => {
+ const store = mockStore({
+ date: {},
+ compare: {
+ isCompareA: false,
+ activeString: 'activeB',
+ },
+ proj: {
+ id: 'geographic',
+ },
+ });
+ const expectedFirst = {
+ type: CLEAR_PRELOAD,
+ };
+ const expectedSecond = {
+ type: CHANGE_INTERVAL,
+ value: interval,
+ delta,
+ customSelected: true,
+ };
+ store.dispatch(selectInterval(delta, interval, true));
+ expect(store.getActions()[0]).toEqual(expectedFirst);
+ expect(store.getActions()[1]).toEqual(expectedSecond);
+ });
});
diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.js
index 8dbb64494..eb93bf56c 100644
--- a/web/js/modules/date/reducers.js
+++ b/web/js/modules/date/reducers.js
@@ -16,7 +16,7 @@ import util from '../../util/util';
export const dateReducerState = {
arrowDown: '',
- lastArrowDirection: '',
+ lastArrowDirection: undefined,
preloaded: false,
lastPreloadDate: undefined,
selectedZoom: 3,
diff --git a/web/js/modules/date/reducers.test.js b/web/js/modules/date/reducers.test.js
index 8b6297e07..75926e9ff 100644
--- a/web/js/modules/date/reducers.test.js
+++ b/web/js/modules/date/reducers.test.js
@@ -77,8 +77,7 @@ describe('dateReducer', () => {
},
);
test(
- `${SELECT_DATE
- }action type and ${mockDate} as value and selected `
+ `${SELECT_DATE} action type and ${mockDate} as value and selected `
+ 'as activeString should return new state',
() => {
expect(