diff options
| author | jpl | 2017-01-25 15:16:39 +0100 |
|---|---|---|
| committer | jpl | 2017-01-25 15:16:39 +0100 |
| commit | 0dc2401e06d28b7fa1d90c8f2f96776483c75c66 (patch) | |
| tree | ada76adf50341dbdf2184a2b5dd6b5285ee4745f /spec/javascripts | |
| parent | 7e34d2737f54f5ced79a0dd836835a769d4439ea (diff) | |
| download | chouette-core-0dc2401e06d28b7fa1d90c8f2f96776483c75c66.tar.bz2 | |
Refs #2405: adding specs to stop points (togglemap, selectmarker...)
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/itineraries/actions_spec.js | 30 | ||||
| -rw-r--r-- | spec/javascripts/itineraries/reducers/stop_points_spec.js | 118 |
2 files changed, 148 insertions, 0 deletions
diff --git a/spec/javascripts/itineraries/actions_spec.js b/spec/javascripts/itineraries/actions_spec.js index f86466375..2bae59987 100644 --- a/spec/javascripts/itineraries/actions_spec.js +++ b/spec/javascripts/itineraries/actions_spec.js @@ -69,3 +69,33 @@ describe('actions', () => { expect(actions.updateSelectValue(event, index)).toEqual(expectedAction) }) }) + +describe('actions', () => { + it('should create an action to toggle the map', () => { + const index = 1 + const expectedAction = { + type: 'TOGGLE_MAP', + index + } + expect(actions.toggleMap(index)).toEqual(expectedAction) + }) +}) + +describe('actions', () => { + it('should create an action to select a marker on the map', () => { + const index = 1 + const data = { + geometry: undefined, + registration_number: 'rn_test', + stoparea_id: 'sid_test', + text: 't_test', + user_objectid: 'uoid_test' + } + const expectedAction = { + type: 'SELECT_MARKER', + index, + data + } + expect(actions.selectMarker(index, data)).toEqual(expectedAction) + }) +}) diff --git a/spec/javascripts/itineraries/reducers/stop_points_spec.js b/spec/javascripts/itineraries/reducers/stop_points_spec.js index b33feab28..fbd33af18 100644 --- a/spec/javascripts/itineraries/reducers/stop_points_spec.js +++ b/spec/javascripts/itineraries/reducers/stop_points_spec.js @@ -2,6 +2,14 @@ var stopPointsReducer = require('es6_browserified/itineraries/reducers/stopPoint let state = [] +let fakeData = { + geometry: undefined, + registration_number: 'rn_test', + stoparea_id: 'sid_test', + text: 't_test', + user_objectid: 'uoid_test' +} + describe('stops reducer', () => { beforeEach(()=>{ state = [ @@ -266,4 +274,114 @@ describe('stops reducer', () => { ] ) }) + + it('should handle SELECT_MARKER', () => { + let openedMapState = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: true, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + expect( + stopPointsReducer(openedMapState, { + type: 'SELECT_MARKER', + index: 0, + data: fakeData + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: true, + json: fakeData + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle UNSELECT_MARKER', () => { + let openedMapState = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: true, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + + expect( + stopPointsReducer(openedMapState, { + type: 'UNSELECT_MARKER', + index: 0 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: true, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) }) |
