-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bf155d
commit 97f6ec3
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import reducer from '../'; | ||
import initialState from '../initialState'; | ||
|
||
it('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual(initialState); | ||
}); | ||
|
||
it('should handle TOGGLE_LOADING', () => { | ||
const action = { | ||
type: 'TOGGLE_LOADING', | ||
}; | ||
|
||
expect(reducer(undefined, action).loading).toEqual(false); // initial is true | ||
}); | ||
|
||
it('should handle SET_DEVICE_LOCATION', () => { | ||
const payload = { | ||
coords: { | ||
lat: 'lat', | ||
lng: 'lng', | ||
}, | ||
}; | ||
|
||
const action = { | ||
type: 'SET_DEVICE_LOCATION', | ||
payload, | ||
}; | ||
|
||
expect(reducer(undefined, action).deviceLocation).toEqual(payload.coords); | ||
}); | ||
|
||
it('should handle SET_SYSTEM_MESSAGE', () => { | ||
const payload = { | ||
message: 'Test', | ||
code: 12345, | ||
}; | ||
|
||
const action = { | ||
type: 'SET_SYSTEM_MESSAGE', | ||
payload, | ||
error: true, | ||
}; | ||
|
||
const expectedPayload = payload; | ||
expectedPayload.error = action.error; | ||
|
||
expect(reducer(undefined, action).systemMessage).toEqual(expectedPayload); | ||
}); | ||
|
||
it('should handle RESET_SYSTEM_MESSAGE', () => { | ||
const action = { | ||
type: 'RESET_SYSTEM_MESSAGE', | ||
}; | ||
|
||
expect(reducer(undefined, action).systemMessage).toEqual(initialState.systemMessage); | ||
}); | ||
|
||
it('should handle SET_NETWORK_CONNECTION_INFO', () => { | ||
const payload = { | ||
network: { | ||
ConnectionType: 'wifi', | ||
EffectiveConnectionType: '4g', | ||
}, | ||
}; | ||
|
||
const action = { | ||
type: 'SET_NETWORK_CONNECTION_INFO', | ||
payload, | ||
}; | ||
|
||
expect(reducer(undefined, action).network).toEqual(payload.network); | ||
}); | ||
|
||
it('should handle TOGGLE_REALTIME_DATABASE_MODE', () => { | ||
const action = { | ||
type: 'TOGGLE_REALTIME_DATABASE_MODE', | ||
}; | ||
|
||
expect(reducer(undefined, action).realtimeDatabaseMode).toEqual(false); // initial is true | ||
}); |