From ddd83906ce4fab3d6dce0c404ec39c3b500ba96f Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 29 Jan 2018 10:32:05 +0100 Subject: Refs #5750; Add a validation on VehicleJourneys Ensure a time is set for all non-commercial stops --- spec/javascript/vehicle_journeys/actions_spec.js | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'spec/javascript') diff --git a/spec/javascript/vehicle_journeys/actions_spec.js b/spec/javascript/vehicle_journeys/actions_spec.js index 9515b57f2..d486c9af8 100644 --- a/spec/javascript/vehicle_journeys/actions_spec.js +++ b/spec/javascript/vehicle_journeys/actions_spec.js @@ -37,6 +37,47 @@ describe('when clicking on add button', () => { expect(actions.openCreateModal()).toEqual(expectedAction) }) }) +describe('when validating the form', () => { + it('should check that non-commercial stops have passing time', () => { + let state = [{ + vehicle_journey_at_stops: [{ + area_kind: "non_commercial", + departure_time: { + hour: "00", + minute: "00" + } + }] + }] + + expect(actions.validate(dispatch, state)).toEqual(false) + + state = [{ + vehicle_journey_at_stops: [{ + area_kind: "non_commercial", + departure_time: { + hour: "00", + minute: "01" + } + }] + }] + + expect(actions.validate(dispatch, state)).toEqual(true) + }) + + it('should not check that commercial stops', () => { + let state = [{ + vehicle_journey_at_stops: [{ + area_kind: "commercial", + departure_time: { + hour: "00", + minute: "00" + } + }] + }] + + expect(actions.validate(dispatch, state)).toEqual(true) + }) +}) describe('when using select2 to pick a journey pattern', () => { it('should create an action to select a journey pattern inside modal', () => { let selectedJP = { -- cgit v1.2.3