Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Jan 26, 2021
1 parent 860f99a commit 28926e0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions x-pack/plugins/maps/public/actions/map_actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ describe('map_actions', () => {
$state: { store: 'appState' },
},
];
const searchSessionId = '1234';

beforeEach(() => {
//Mocks the "previous" state
Expand All @@ -272,6 +273,9 @@ describe('map_actions', () => {
require('../selectors/map_selectors').getFilters = () => {
return filters;
};
require('../selectors/map_selectors').getSearchSessionId = () => {
return searchSessionId;
};
require('../selectors/map_selectors').getMapSettings = () => {
return {
autoFitToDataBounds: false,
Expand All @@ -288,12 +292,14 @@ describe('map_actions', () => {
const setQueryAction = await setQuery({
query: newQuery,
filters,
searchSessionId,
});
await setQueryAction(dispatchMock, getStoreMock);

expect(dispatchMock.mock.calls).toEqual([
[
{
searchSessionId,
timeFilters,
query: newQuery,
filters,
Expand All @@ -304,11 +310,25 @@ describe('map_actions', () => {
]);
});

it('should dispatch query action when searchSessionId changes', async () => {
const setQueryAction = await setQuery({
timeFilters,
query,
filters,
searchSessionId: '5678',
});
await setQueryAction(dispatchMock, getStoreMock);

// dispatchMock calls: dispatch(SET_QUERY) and dispatch(syncDataForAllLayers())
expect(dispatchMock.mock.calls.length).toEqual(2);
});

it('should not dispatch query action when nothing changes', async () => {
const setQueryAction = await setQuery({
timeFilters,
query,
filters,
searchSessionId,
});
await setQueryAction(dispatchMock, getStoreMock);

Expand Down

0 comments on commit 28926e0

Please sign in to comment.