Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created December 16, 2015 21:50
Show Gist options
  • Save iammerrick/49b4420d64f954fa6c5e to your computer and use it in GitHub Desktop.
Save iammerrick/49b4420d64f954fa6c5e to your computer and use it in GitHub Desktop.
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);
});
});
@ryanflorence
Copy link

if you decided to change [x], you have to change [y]

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 💯

@ryanflorence
Copy link

(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