diff options
| author | Thomas Haddad | 2016-11-17 17:42:29 +0100 |
|---|---|---|
| committer | Thomas Haddad | 2016-11-17 17:43:10 +0100 |
| commit | 3fb20fcc5ca5c39fae2c793e822eac1a2b2f6cb7 (patch) | |
| tree | 2817bf343a3255f9bd2049c32b772c290b7dd6b2 /spec/javascripts | |
| parent | 7efedaa1147b43a8a85e0c5eed6b512628c011db (diff) | |
| download | chouette-core-3fb20fcc5ca5c39fae2c793e822eac1a2b2f6cb7.tar.bz2 | |
Add reducers tests, some skipped until better es6 support while testing
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/reducers_spec.js | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/spec/javascripts/reducers_spec.js b/spec/javascripts/reducers_spec.js new file mode 100644 index 000000000..a4880e73e --- /dev/null +++ b/spec/javascripts/reducers_spec.js @@ -0,0 +1,178 @@ +var reducer = require('es6_browserified/reducers/todos') +let state = [] +describe('stops reducer', () => { + beforeEach(()=>{ + state = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + }) + + it('should return the initial state', () => { + expect( + reducer(undefined, {}) + ).toEqual([]) + }) + + it('should handle ADD_STOP', () => { + expect( + reducer(state, { + type: 'ADD_STOP' + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: '', + index: 2, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle MOVE_UP_STOP', () => { + expect( + reducer(state, { + type: 'MOVE_STOP_UP', + index: 1 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle MOVE_DOWN_STOP', () => { + expect( + reducer(state, { + type: 'MOVE_STOP_DOWN', + index: 0 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + it('should handle DELETE_STOP', () => { + expect( + reducer(state, { + type: 'DELETE_STOP', + index: 1 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + //TODO unskip when es6 is properly functionnal + xit('should handle UPDATE_INPUT_VALUE', () => { + expect( + reducer(state, { + type: 'UPDATE_INPUT_VALUE', + index: 0, + text: { + text: "new value", + stoparea_id: 1 + } + }) + ).toEqual( + [ + { + text: 'new value', + index: 0, + stoparea_id: 1, + for_boarding: 'normal', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) + + xit('should handle UPDATE_SELECT_VALUE', () => { + expect( + reducer(state, { + type :'UPDATE_SELECT_VALUE', + select_id: 'for_boarding', + select_value: 'prohibited', + index: 0 + }) + ).toEqual( + [ + { + text: 'new value', + index: 0, + stoparea_id: 1, + for_boarding: 'prohibited', + for_alighting: 'normal' + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal' + } + ] + ) + }) +}) |
