diff options
| author | Zog | 2017-12-28 11:22:41 +0100 |
|---|---|---|
| committer | Zog | 2017-12-28 11:22:43 +0100 |
| commit | 09dcd818d83a1dddef4e4f2e3fd800fb228c51c0 (patch) | |
| tree | dd32f2131c15dc8d79ab3c927d9ec9a79f4f8495 /spec/javascript | |
| parent | d6b14504f350e4bf5de3d7a68928c433fef70de7 (diff) | |
| download | chouette-core-09dcd818d83a1dddef4e4f2e3fd800fb228c51c0.tar.bz2 | |
Refs #5435 @0.5h; Fix EditModal validation in VehicleJourneys#index
Diffstat (limited to 'spec/javascript')
| -rw-r--r-- | spec/javascript/vehicle_journeys/actions_spec.js | 58 |
1 files changed, 49 insertions, 9 deletions
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', () => { |
