aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/vehicle_journeys/actions_spec.js52
-rw-r--r--spec/javascripts/vehicle_journeys/reducers/modal_spec.js8
-rw-r--r--spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js21
3 files changed, 81 insertions, 0 deletions
diff --git a/spec/javascripts/vehicle_journeys/actions_spec.js b/spec/javascripts/vehicle_journeys/actions_spec.js
index 5eb3abe45..9f3f5e168 100644
--- a/spec/javascripts/vehicle_journeys/actions_spec.js
+++ b/spec/javascripts/vehicle_journeys/actions_spec.js
@@ -29,6 +29,58 @@ describe('when receiveJourneyPatterns is triggered', () => {
expect(actions.receiveVehicleJourneys()).toEqual(expectedAction)
})
})
+describe('when clicking on add button', () => {
+ it('should create an action to open a create modal', () => {
+ const expectedAction = {
+ type: 'CREATE_VEHICLEJOURNEY_MODAL',
+ }
+ expect(actions.openCreateModal()).toEqual(expectedAction)
+ })
+})
+describe('when clicking on validate button inside create modal', () => {
+ it('should create an action to create a new journey pattern', () => {
+ const data = {}
+ const expectedAction = {
+ type: 'ADD_VEHICLEJOURNEY',
+ data
+ }
+ expect(actions.addVehicleJourney(data)).toEqual(expectedAction)
+ })
+})
+describe('when previous navigation button is clicked', () => {
+ it('should create an action to go to previous page', () => {
+ const nextPage = false
+ const pagination = {
+ totalCount: 25,
+ perPage: 12,
+ page:1
+ }
+ const expectedAction = {
+ type: 'GO_TO_PREVIOUS_PAGE',
+ dispatch,
+ pagination,
+ nextPage
+ }
+ expect(actions.goToPreviousPage(dispatch, pagination)).toEqual(expectedAction)
+ })
+})
+describe('when next navigation button is clicked', () => {
+ it('should create an action to go to next page', () => {
+ const nextPage = true
+ const pagination = {
+ totalCount: 25,
+ perPage: 12,
+ page:1
+ }
+ const expectedAction = {
+ type: 'GO_TO_NEXT_PAGE',
+ dispatch,
+ pagination,
+ nextPage
+ }
+ expect(actions.goToNextPage(dispatch, pagination)).toEqual(expectedAction)
+ })
+})
describe('when toggling arrivals', () => {
it('should create an action to toggleArrivals', () => {
const expectedAction = {
diff --git a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js
index 8da8e6c65..8e854be40 100644
--- a/spec/javascripts/vehicle_journeys/reducers/modal_spec.js
+++ b/spec/javascripts/vehicle_journeys/reducers/modal_spec.js
@@ -34,6 +34,14 @@ describe('modal reducer', () => {
).toEqual(newState)
})
+ it('should handle CREATE_VEHICLEJOURNEY_MODAL', () => {
+ expect(
+ modalReducer(state, {
+ type: 'CREATE_VEHICLEJOURNEY_MODAL'
+ })
+ ).toEqual(Object.assign({}, state, { type: 'create' }))
+ })
+
it('should handle CLOSE_MODAL', () => {
expect(
modalReducer(state, {
diff --git a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js
index 5540caf02..bb40add3a 100644
--- a/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js
+++ b/spec/javascripts/vehicle_journeys/reducers/vehicle_journeys_spec.js
@@ -55,6 +55,27 @@ describe('vehicleJourneys reducer', () => {
})
+ it('should handle ADD_VEHICLEJOURNEY', () => {
+ let fakeData = {
+ journey_pattern_id: {value : '1'},
+ comment: {value: 'test'}
+ }
+ expect(
+ vjReducer(state, {
+ type: 'ADD_VEHICLEJOURNEY',
+ data: fakeData
+ })
+ ).toEqual([{
+ journey_pattern_id: 1,
+ comment: 'test',
+ objectid: '',
+ footnotes: [],
+ time_tables: [],
+ vehicle_journey_at_stops: [],
+ deletable: false
+ }, ...state])
+ })
+
it('should handle RECEIVE_VEHICLE_JOURNEYS', () => {
expect(
vjReducer(state, {