Skip to content

Instantly share code, notes, and snippets.

@david-mart
Created September 7, 2017 17:31
Show Gist options
  • Save david-mart/9166ee9ef00f6830573264f5ce86b624 to your computer and use it in GitHub Desktop.
Save david-mart/9166ee9ef00f6830573264f5ce86b624 to your computer and use it in GitHub Desktop.
/* eslint-disable max-nested-callbacks */
import { expect } from 'chai';
import { toggleProjectInfoWindow, setDrawingMode, setMapFilters } from './map-actions';
import { MAP_CLOSE_INFO_WINDOW, MAP_SET_DRAWING_MODE, MAP_FILTERS_CHANGED } from '../constants/action-types';
import thunk from 'redux-thunk';
import configureMockStore from 'redux-mock-store';
describe('Map Actions', () => {
const state = {
map: {
infoWindows: [{ projectId: 1 }, { projectId: 2 }],
drawing: { mode: 'circle' },
filters: {}
}
};
const existingProjectId = 2;
let store;
beforeEach(() => {
store = configureMockStore([thunk])(state);
});
describe('setMapFilters', () => {
it('should dispatch MAP_FILTERS_CHANGED action', () => {
const expected = MAP_FILTERS_CHANGED;
store.dispatch(setMapFilters({}));
const actual = store.getActions()[0].type;
expect(actual).equals(expected);
});
});
describe('toggleProjectInfoWindow', () => {
it('should dispatch MAP_CLOSE_INFO_WINDOW if passed project id is already in the list', () => {
const expected = MAP_CLOSE_INFO_WINDOW;
store.dispatch(toggleProjectInfoWindow(existingProjectId));
const actual = store.getActions()[0].type;
expect(actual).equals(expected);
});
});
describe('setDrawingMode', () => {
it('should dispatch MAP_SET_DRAWING_MODE action', () => {
const expected = MAP_SET_DRAWING_MODE;
store.dispatch(setDrawingMode('polygon'));
const actual = store.getActions()[0].type;
expect(actual).equals(expected);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment