-
-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add selectors and tests for unreadReducers (#885)
- Loading branch information
1 parent
51bc009
commit 81a481e
Showing
12 changed files
with
435 additions
and
59 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
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
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
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
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
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
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
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
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,59 @@ | ||
import deepFreeze from 'deep-freeze'; | ||
|
||
import unreadReducers from '../unreadReducers'; | ||
import { REALM_INIT, ACCOUNT_SWITCH } from '../../actionConstants'; | ||
|
||
describe('unreadReducers', () => { | ||
describe('ACCOUNT_SWITCH', () => { | ||
test('resets state to initial state', () => { | ||
const initialState = deepFreeze(['some_stream']); | ||
|
||
const action = deepFreeze({ | ||
type: ACCOUNT_SWITCH, | ||
}); | ||
|
||
const expectedState = { | ||
streams: [], | ||
huddles: [], | ||
pms: [], | ||
}; | ||
|
||
const actualState = unreadReducers(initialState, action); | ||
|
||
expect(actualState).toEqual(expectedState); | ||
}); | ||
}); | ||
|
||
describe('REALM_INIT', () => { | ||
test('received data from "unread_msgs" key replaces the current state ', () => { | ||
const initialState = deepFreeze({ | ||
streams: [], | ||
huddles: [], | ||
pms: [], | ||
}); | ||
|
||
const unreadMsgsData = { | ||
streams: [ | ||
{ | ||
stream_id: 1, | ||
topic: 'some topic', | ||
unread_message_ids: [1, 2, 3], | ||
}, | ||
], | ||
huddles: [], | ||
pms: [], | ||
}; | ||
|
||
const action = deepFreeze({ | ||
type: REALM_INIT, | ||
data: { | ||
unread_msgs: unreadMsgsData, | ||
}, | ||
}); | ||
|
||
const actualState = unreadReducers(initialState, action); | ||
|
||
expect(actualState).toBe(unreadMsgsData); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.