Created
December 16, 2015 21:50
-
-
Save iammerrick/49b4420d64f954fa6c5e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import expect from 'expect'; | |
import AppConstants from '../../../app/AppConstants'; | |
import store from '../../store'; | |
import { selectLastReadMessageByChannelId } from './channelSelectors'; | |
describe('channel', () => { | |
it('should store the messageId when clearing unreads', () => { | |
const channelId = 1; | |
const messageId = 2; | |
store.dispatch({ | |
type: AppConstants.CHANNEL_UNREADS_CLEARED, | |
payload: { | |
id: channelId, | |
messageId | |
} | |
}); | |
expect(selectLastReadMessageByChannelId(store.getState(), channelId)).toEqual(messageId); | |
}); | |
}); |
(there are times I look at how simple my reducers--and everything else in a react redux app--are to think about and wonder why I'm even writing tests at all ...)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apps always change. For me, about the only thing I care about is that.
My favorite code allows me to change one thing w/o having to change many things.
For example, I don't assert an exact DOM structure for UI tests, I just assert that the user's name is displayed: I don't care if its in a
<b/>
or<span/>
. You've got the same thing going on here by not coupling your tests to your state tree, you're testing "does this work" not "how does this work" and its 💯