Last active
August 18, 2017 11:56
-
-
Save tomfa/20032a5d1b636e402796c2d37ff6e624 to your computer and use it in GitHub Desktop.
Redux state test example
This file contains 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'; | |
import reducer from '../../reducers/installations'; | |
describe('reducers/installations', () => { | |
let state; | |
beforeEach(() => { | |
state = { | |
installations: [], | |
isLoading: False, | |
}; | |
}); | |
it('should not change state for unknown actions', () => { | |
let newState = reducer(state, { type: 'UNKNOWN_TYPE' }); | |
expect(newState).to.equal(state); | |
}); | |
it('should be loading on INSTALLATION_REQUESTED', () => { | |
let newState = reducer(state, { | |
type: INSTALLATION_REQUESTED, | |
}); | |
expect(newState).to.deep.equal({ | |
installations: [], | |
isLoading: True, | |
}); | |
}); | |
it('should populate installations on INSTALLATION_RECEIVED', () => { | |
let newState = reducer(state, { | |
type: INSTALLATION_RECEIVED, | |
installation: { | |
address: 'The Road 1', | |
country: 'Norway', | |
}, | |
}); | |
expect(newState).to.deep.equal({ | |
installations: [{ | |
address: 'The Road 1', | |
country: 'Norway', | |
}], | |
isLoading: True, | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment