Created
October 6, 2015 04:35
-
-
Save dnasca/f96476963457c44f4683 to your computer and use it in GitHub Desktop.
an example of testing an immutable data structure
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 'chai'; | |
describe('immutability', () => { | |
describe('a number', () => { | |
function increment(currentState) { | |
return currentState + 1; | |
} | |
it('is immutable', () => { | |
let state = 42; | |
let nextState = increment(state); | |
expect(nextState).to.equal(43); | |
expect(state).to.equal(42); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment