Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created October 6, 2015 04:35
Show Gist options
  • Save dnasca/f96476963457c44f4683 to your computer and use it in GitHub Desktop.
Save dnasca/f96476963457c44f4683 to your computer and use it in GitHub Desktop.
an example of testing an immutable data structure
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