diff options
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/time_table/actions_spec.js | 27 | ||||
| -rw-r--r-- | spec/javascripts/time_table/reducers/metas_spec.js | 49 | ||||
| -rw-r--r-- | spec/javascripts/vehicle_journeys/reducers/filters_spec.js | 8 |
3 files changed, 80 insertions, 4 deletions
diff --git a/spec/javascripts/time_table/actions_spec.js b/spec/javascripts/time_table/actions_spec.js new file mode 100644 index 000000000..c628a0f57 --- /dev/null +++ b/spec/javascripts/time_table/actions_spec.js @@ -0,0 +1,27 @@ +var actions = require('es6_browserified/time_tables/actions') + +describe('actions', () => { + it('should create an action to update dayTypes', () => { + const expectedAction = { + type: 'UPDATE_DAY_TYPES', + index: 1 + } + expect(actions.updateDayTypes(1)).toEqual(expectedAction) + }) + + it('should create an action to update comment', () => { + const expectedAction = { + type: 'UPDATE_COMMENT', + comment: 'test' + } + expect(actions.updateComment('test')).toEqual(expectedAction) + }) + + it('should create an action to update color', () => { + const expectedAction = { + type: 'UPDATE_COLOR', + color: '#ffffff' + } + expect(actions.updateColor('#ffffff')).toEqual(expectedAction) + }) +}) diff --git a/spec/javascripts/time_table/reducers/metas_spec.js b/spec/javascripts/time_table/reducers/metas_spec.js new file mode 100644 index 000000000..e3729dc2a --- /dev/null +++ b/spec/javascripts/time_table/reducers/metas_spec.js @@ -0,0 +1,49 @@ +var metasReducer = require('es6_browserified/time_tables/reducers/metas') + +let state = {} + +describe('status reducer', () => { + beforeEach(() => { + state = { + comment: 'test', + day_types: [true, true, true, true, true, true, true], + tags: ['t1'], + color: 'blue' + } + }) + + it('should return the initial state', () => { + expect( + metasReducer(undefined, {}) + ).toEqual({}) + }) + + it('should handle UPDATE_DAY_TYPES', () => { + const arr = [false, true, true, true, true, true, true] + expect( + metasReducer(state, { + type: 'UPDATE_DAY_TYPES', + index: 0 + }) + ).toEqual(Object.assign({}, state, {day_types: arr})) + }) + + it('should handle UPDATE_COMMENT', () => { + expect( + metasReducer(state, { + type: 'UPDATE_COMMENT', + comment: 'title' + }) + ).toEqual(Object.assign({}, state, {comment: 'title'})) + }) + + it('should handle UPDATE_COLOR', () => { + expect( + metasReducer(state, { + type: 'UPDATE_COLOR', + color: '#ffffff' + }) + ).toEqual(Object.assign({}, state, {color: '#ffffff'})) + }) + +}) diff --git a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js index 84608243b..d5cdff430 100644 --- a/spec/javascripts/vehicle_journeys/reducers/filters_spec.js +++ b/spec/javascripts/vehicle_journeys/reducers/filters_spec.js @@ -29,7 +29,7 @@ describe('filters reducer', () => { }, journeyPattern: {}, timetable: {}, - withoutSchedule: false, + withoutSchedule: true, }, queryString: '' } @@ -61,7 +61,7 @@ describe('filters reducer', () => { it('should handle TOGGLE_WITHOUT_SCHEDULE', () => { let rslt = JSON.parse(JSON.stringify(state.query)) - rslt.withoutSchedule = true + rslt.withoutSchedule = false expect( statusReducer(state, { type: 'TOGGLE_WITHOUT_SCHEDULE' @@ -143,8 +143,8 @@ describe('filters reducer', () => { ).toEqual(Object.assign({}, state, {query: newQuery})) }) - it('should handle SELECT_JP_FILTER', () => { - let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22" + it('should handle CREATE_QUERY_STRING', () => { + let strResult = "q%5Bjourney_pattern_id_eq%5D=undefined&q%5Btime_tables_id_eq%5D=undefined&q%5Bvehicle_journey_at_stops_departure_time_gteq%5D=11%3A11&q%5Bvehicle_journey_at_stops_departure_time_lteq%5D=22%3A22&q%5Bvehicle_journey_without_departure_time%5D=true" expect( statusReducer(state, { type: 'CREATE_QUERY_STRING', |
