aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpl2017-01-18 09:40:47 +0100
committerjpl2017-01-18 09:40:47 +0100
commitf7009121b1cbc421efd079bfb4cc43d91ab7ca28 (patch)
treeb5aef7364a67c9d8178549705c13cdef016cfce6
parent1840777c674a9c62aff315b47518f154e5c92577 (diff)
downloadchouette-core-f7009121b1cbc421efd079bfb4cc43d91ab7ca28.tar.bz2
Refs #2404: adding toggle_map tests, fixing also add_stop_point reducer
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/index.js4
-rw-r--r--app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js6
-rw-r--r--spec/javascripts/itineraries/components_spec.js40
-rw-r--r--spec/javascripts/itineraries/reducers/stop_points_spec.js (renamed from spec/javascripts/itineraries/reducers_spec.js)134
4 files changed, 119 insertions, 65 deletions
diff --git a/app/assets/javascripts/es6_browserified/itineraries/index.js b/app/assets/javascripts/es6_browserified/itineraries/index.js
index ee78bc7a9..e0f5d0bc7 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/index.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/index.js
@@ -31,9 +31,9 @@ const getInitialState = () => {
text: fancyText,
for_boarding: value.for_boarding || "normal",
for_alighting: value.for_alighting || "normal",
- olMap:{
+ olMap: {
isOpened: false,
- json: {},
+ json: {}
}
})
}
diff --git a/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js b/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js
index a66ff5453..40fb2982f 100644
--- a/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js
+++ b/app/assets/javascripts/es6_browserified/itineraries/reducers/stopPoints.js
@@ -7,7 +7,11 @@ const stopPoint = (state = {}, action, length) => {
text: '',
index: length,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
default:
return state
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_spec.js b/spec/javascripts/itineraries/reducers/stop_points_spec.js
index 344cccab5..b33feab28 100644
--- a/spec/javascripts/itineraries/reducers_spec.js
+++ b/spec/javascripts/itineraries/reducers/stop_points_spec.js
@@ -1,5 +1,7 @@
-var reducer = require('es6_browserified/itineraries/reducers/stopPoints')
+var stopPointsReducer = require('es6_browserified/itineraries/reducers/stopPoints')
+
let state = []
+
describe('stops reducer', () => {
beforeEach(()=>{
state = [
@@ -7,26 +9,34 @@ describe('stops reducer', () => {
text: 'first',
index: 0,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
})
it('should return the initial state', () => {
expect(
- reducer(undefined, {})
+ stopPointsReducer(undefined, {})
).toEqual([])
})
it('should handle ADD_STOP', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type: 'ADD_STOP'
})
).toEqual(
@@ -35,19 +45,31 @@ describe('stops reducer', () => {
text: 'first',
index: 0,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: '',
index: 2,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)
@@ -55,7 +77,7 @@ describe('stops reducer', () => {
it('should handle MOVE_UP_STOP', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type: 'MOVE_STOP_UP',
index: 1
})
@@ -65,13 +87,21 @@ describe('stops reducer', () => {
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'first',
index: 0,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)
@@ -79,7 +109,7 @@ describe('stops reducer', () => {
it('should handle MOVE_DOWN_STOP', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type: 'MOVE_STOP_DOWN',
index: 0
})
@@ -89,13 +119,21 @@ describe('stops reducer', () => {
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'first',
index: 0,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)
@@ -103,7 +141,7 @@ describe('stops reducer', () => {
it('should handle DELETE_STOP', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type: 'DELETE_STOP',
index: 1
})
@@ -113,7 +151,11 @@ describe('stops reducer', () => {
text: 'first',
index: 0,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)
@@ -121,7 +163,7 @@ describe('stops reducer', () => {
it('should handle UPDATE_INPUT_VALUE', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type: 'UPDATE_INPUT_VALUE',
index: 0,
text: {
@@ -139,13 +181,21 @@ describe('stops reducer', () => {
stoparea_id: 1,
for_boarding: 'normal',
for_alighting: 'normal',
- user_objectid: "1234"
+ user_objectid: "1234",
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)
@@ -153,7 +203,7 @@ describe('stops reducer', () => {
it('should handle UPDATE_SELECT_VALUE', () => {
expect(
- reducer(state, {
+ stopPointsReducer(state, {
type :'UPDATE_SELECT_VALUE',
select_id: 'for_boarding',
select_value: 'prohibited',
@@ -165,13 +215,53 @@ describe('stops reducer', () => {
text: 'first',
index: 0,
for_boarding: 'prohibited',
- for_alighting: 'normal'
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
},
{
text: 'second',
index: 1,
for_boarding: 'normal',
- for_alighting: '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: 'second',
+ index: 1,
+ for_boarding: 'normal',
+ for_alighting: 'normal',
+ olMap: {
+ isOpened: false,
+ json: {}
+ }
}
]
)