Skip to content

Instantly share code, notes, and snippets.

@alexbrillant
Created May 12, 2017 18:30
Show Gist options
  • Save alexbrillant/6db79e9cdc79248bab96201f413d52a3 to your computer and use it in GitHub Desktop.
Save alexbrillant/6db79e9cdc79248bab96201f413d52a3 to your computer and use it in GitHub Desktop.
import {
nearestBranchRequest,
nearestBranchSuccess,
nearestBranchFailure,
INITIAL_STATE
} from '../branchReducer';
describe('branch reducer tests', () => {
it('given latitude and longitude when nearestBranchRequest then should set latitude, longitude and searching to true', () => {
const latitude = 1;
const longitude = 1;
const state = nearestBranchRequest(INITIAL_STATE, {
payload: { latitude, longitude }
});
const expectedState = {
...INITIAL_STATE,
latitude,
longitude,
searching: true
};
expect(state).toEqual(expectedState);
});
it('given nearest branch when nearestBranchSuccess then should set nearestBranch and searching to false', () => {
const nearestBranch = 100;
const state = nearestBranchSuccess(INITIAL_STATE, {
payload: { nearestBranch: nearestBranch }
});
const expectedState = {
...INITIAL_STATE,
nearestBranch: nearestBranch,
searching: false
};
expect(state).toEqual(expectedState);
});
it('when nearestBranchFailure then should set searching to false', () => {
const state = nearestBranchFailure({ ...INITIAL_STATE, searching: true });
const expectedState = { ...INITIAL_STATE, searching: false };
expect(state).toEqual(expectedState);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment