Last active
July 2, 2018 00:14
-
-
Save lupomontero/e315116befab50ff0e88c3d736cd353f 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
const reducer = require('./reducer-1'); | |
describe('reducer()', () => { | |
it('should not be affected by previous calls', () => { | |
expect(reducer(undefined, { type: 'INCREMENT' })).toEqual({ count: 1 }); | |
expect(reducer(undefined, { type: 'INCREMENT' })).toEqual({ count: 1 }); | |
expect(reducer(undefined, { type: 'DECREMENT' })).toEqual({ count: -1 }); | |
}); | |
it('should handle increment action', () => { | |
const state1 = reducer(undefined, { type: 'INCREMENT' }); | |
const state2 = reducer(state1, { type: 'INCREMENT' }); | |
// Todas las referencias a state apuntan al mismo objeto que | |
// hemos ido mutando!!! | |
expect(state1).toEqual({ count: 2 }); | |
expect(state2).toEqual({ count: 2 }); | |
expect(state1).toBe(state2); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment