From 09dcd818d83a1dddef4e4f2e3fd800fb228c51c0 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 28 Dec 2017 11:22:41 +0100 Subject: Refs #5435 @0.5h; Fix EditModal validation in VehicleJourneys#index --- spec/javascript/vehicle_journeys/actions_spec.js | 58 ++++++++++++++++++++---- 1 file changed, 49 insertions(+), 9 deletions(-) (limited to 'spec/javascript') diff --git a/spec/javascript/vehicle_journeys/actions_spec.js b/spec/javascript/vehicle_journeys/actions_spec.js index 3af19ebc3..2f1daf0da 100644 --- a/spec/javascript/vehicle_journeys/actions_spec.js +++ b/spec/javascript/vehicle_journeys/actions_spec.js @@ -174,15 +174,55 @@ describe('when clicking on validate button inside shifting modal', () => { }) }) describe('when clicking on validate button inside editing modal', () => { - it('should create an action to update a vehiclejourney', () => { - const data = {} - const selectedCompany = {} - const expectedAction = { - type: 'EDIT_VEHICLEJOURNEY', - data, - selectedCompany - } - expect(actions.editVehicleJourney(data, selectedCompany)).toEqual(expectedAction) + context("with invalid data", () => { + it('should not validate the data', () => { + const data = { + foo: { + validity: { valid: false } + }, + bar: { + validity: { valid: true } + } + } + + expect(actions.validateFields(data)).toBeFalsy + }) + }) + + context("with data not needing validation", () => { + it('should validate the data', () => { + const data = { + foo: {} + } + + expect(actions.validateFields(data)).toBeTruthy + }) + }) + context("with valid data", () => { + it('should validate the data', () => { + const data = { + foo: { + validity: { valid: true } + }, + bar: { + validity: { valid: true } + } + } + + expect(actions.validateFields(data)).toBeTruthy + }) + }) + context("once the data has been validated", () => { + it('should create an action to update a vehiclejourney', () => { + const data = {} + const selectedCompany = {} + const expectedAction = { + type: 'EDIT_VEHICLEJOURNEY', + data, + selectedCompany + } + expect(actions.editVehicleJourney(data, selectedCompany)).toEqual(expectedAction) + }) }) }) describe('when clicking on validate button inside duplicating modal', () => { -- cgit v1.2.3