diff options
| author | Thomas Haddad | 2017-01-30 16:31:36 +0100 |
|---|---|---|
| committer | Thomas Haddad | 2017-01-30 16:31:36 +0100 |
| commit | c9d8a8e34ea5fec55eb2c8c4b137d7c31752db45 (patch) | |
| tree | b5b05c7aa69fad4c495269444e94fb5e316a23d7 /spec | |
| parent | 8ce5d4f67210990e22a716b82a7d3fb634d80fa9 (diff) | |
| parent | dd6d75b90a610b100f4a8b9eb14b8811b19e9d33 (diff) | |
| download | chouette-core-c9d8a8e34ea5fec55eb2c8c4b137d7c31752db45.tar.bz2 | |
Merge branch 'itineraries_ol'
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/javascripts/itineraries/actions_spec.js | 30 | ||||
| -rw-r--r-- | spec/javascripts/itineraries/components_spec.js | 40 | ||||
| -rw-r--r-- | spec/javascripts/itineraries/reducers/stop_points_spec.js | 401 | ||||
| -rw-r--r-- | spec/javascripts/itineraries/reducers_spec.js | 179 |
4 files changed, 431 insertions, 219 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/components_spec.js b/spec/javascripts/itineraries/components_spec.js deleted file mode 100644 index c9c57b5eb..000000000 --- a/spec/javascripts/itineraries/components_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -// var React = require('react'); -// var Provider = require('react-redux').Provider; -// var actions = require('es6_browserified/itineraries/actions/index'); -// var App = require('es6_browserified/itineraries/components/TodoList'); -// var ConnectedApp = require('es6_browserified/itineraries/containers/VisibleTodoList'); -// var TestUtils = require('react-addons-test-utils'); - -// xdescribe('ConnectedApp', function() { -// var connectedApp, store, initialItems; -// var state; -// state = [ -// { -// text: 'first', -// index: 0, -// for_boarding: 'normal', -// for_alighting: 'normal' -// }, -// { -// text: 'second', -// index: 1, -// for_boarding: 'normal', -// for_alighting: 'normal' -// } -// ] - -// beforeEach(function() { -// store = state -// }); - -// describe('state provided by the store', function() { -// beforeEach(function() { -// connectedApp = TestUtils.renderIntoDocument(<Provider store={store}><ConnectedApp/></Provider>); -// }); - -// it('passes down items', function() { -// app = TestUtils.findRenderedComponentWithType(connectedApp, App); -// expect(app.props.items).toEqual(initialItems); -// }); -// }); -// }); diff --git a/spec/javascripts/itineraries/reducers/stop_points_spec.js b/spec/javascripts/itineraries/reducers/stop_points_spec.js new file mode 100644 index 000000000..d6917f782 --- /dev/null +++ b/spec/javascripts/itineraries/reducers/stop_points_spec.js @@ -0,0 +1,401 @@ +var stopPointsReducer = require('es6_browserified/itineraries/reducers/stopPoints') + +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 = [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + }) + + it('should return the initial state', () => { + expect( + stopPointsReducer(undefined, {}) + ).toEqual([]) + }) + + it('should handle ADD_STOP', () => { + expect( + stopPointsReducer(state, { + type: 'ADD_STOP' + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: '', + index: 2, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle MOVE_UP_STOP', () => { + expect( + stopPointsReducer(state, { + type: 'MOVE_STOP_UP', + index: 1 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle MOVE_DOWN_STOP', () => { + expect( + stopPointsReducer(state, { + type: 'MOVE_STOP_DOWN', + index: 0 + }) + ).toEqual( + [ + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle DELETE_STOP', () => { + expect( + stopPointsReducer(state, { + type: 'DELETE_STOP', + index: 1 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle UPDATE_INPUT_VALUE', () => { + expect( + stopPointsReducer(state, { + type: 'UPDATE_INPUT_VALUE', + index: 0, + text: { + text: "new value", + name: 'new', + stoparea_id: 1, + user_objectid: "1234", + longitude: 123, + latitude: 123, + registration_number: '0' + } + }) + ).toEqual( + [ + { + text: 'new value', + name: 'new', + index: 0, + stoppoint_id: '', + stoparea_id: 1, + for_boarding: 'normal', + for_alighting: 'normal', + user_objectid: "1234", + longitude: 123, + latitude: 123, + registration_number: '0', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle UPDATE_SELECT_VALUE', () => { + expect( + stopPointsReducer(state, { + type :'UPDATE_SELECT_VALUE', + select_id: 'for_boarding', + select_value: 'prohibited', + index: 0 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'prohibited', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + it('should handle TOGGLE_MAP', () => { + expect( + stopPointsReducer(state, { + type: 'TOGGLE_MAP', + index: 0 + }) + ).toEqual( + [ + { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: true, + json: { + text: 'first', + index: 0, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: undefined + } + } + }, + { + text: 'second', + index: 1, + for_boarding: 'normal', + for_alighting: 'normal', + olMap: { + isOpened: false, + json: {} + } + } + ] + ) + }) + + 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: {} + } + } + ] + ) + }) +}) diff --git a/spec/javascripts/itineraries/reducers_spec.js b/spec/javascripts/itineraries/reducers_spec.js deleted file mode 100644 index a8731af5f..000000000 --- a/spec/javascripts/itineraries/reducers_spec.js +++ /dev/null @@ -1,179 +0,0 @@ -var reducer = require('es6_browserified/itineraries/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' - } - ] - ) - }) - - it('should handle UPDATE_INPUT_VALUE', () => { - expect( - reducer(state, { - type: 'UPDATE_INPUT_VALUE', - index: 0, - text: { - text: "new value", - stoparea_id: 1, - user_objectid: "1234" - } - }) - ).toEqual( - [ - { - text: 'new value', - index: 0, - stoppoint_id: '', - stoparea_id: 1, - for_boarding: 'normal', - for_alighting: 'normal', - user_objectid: "1234" - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) - - it('should handle UPDATE_SELECT_VALUE', () => { - expect( - reducer(state, { - type :'UPDATE_SELECT_VALUE', - select_id: 'for_boarding', - select_value: 'prohibited', - index: 0 - }) - ).toEqual( - [ - { - text: 'first', - index: 0, - for_boarding: 'prohibited', - for_alighting: 'normal' - }, - { - text: 'second', - index: 1, - for_boarding: 'normal', - for_alighting: 'normal' - } - ] - ) - }) -}) |
