From d0e51ea2058163b76863797a4e337ba3f5d6611d Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 10:08:34 +0100 Subject: Refs #5437 @0.5h; Propagate behaviour to the JourneyPatterns editor --- .../components/JourneyPatterns_spec.js | 77 ++++++++++ .../__snapshots__/JourneyPatterns_spec.js.snap | 169 +++++++++++++++++++++ .../components/VehicleJourneys_spec.js | 9 +- .../__snapshots__/VehicleJourneys_spec.js.snap | 12 ++ 4 files changed, 264 insertions(+), 3 deletions(-) create mode 100644 spec/javascript/journey_patterns/components/JourneyPatterns_spec.js create mode 100644 spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap (limited to 'spec/javascript') diff --git a/spec/javascript/journey_patterns/components/JourneyPatterns_spec.js b/spec/javascript/journey_patterns/components/JourneyPatterns_spec.js new file mode 100644 index 000000000..0c852deff --- /dev/null +++ b/spec/javascript/journey_patterns/components/JourneyPatterns_spec.js @@ -0,0 +1,77 @@ +import React, { Component } from 'react' +import JourneyPatterns from '../../../../app/javascript/journey_patterns/components/JourneyPatterns' +import renderer from 'react-test-renderer' + +describe('stopPointHeader', () => { + set('features', () => { + return {} + }) + set('component', () => { + let props = { + status: { + features: features + }, + onCheckboxChange: ()=>{}, + onLoadFirstPage: ()=>{}, + onOpenEditModal: ()=>{}, + stopPointsList: [stop_point, same_city_stop_point, other_country_stop_point], + journeyPatterns: [] + } + let list = renderer.create( + + ).toJSON() + + return list + }) + + set('stop_point', () => { + return { + name: "Stop point", + city_name: "City Name", + zip_code: "12345", + country_code: "FR", + country_name: "france", + object_id: "sp-FR" + } + }) + + set('same_city_stop_point', () => { + return { + name: "Antother stop point", + city_name: stop_point.city_name, + zip_code: stop_point.zip_code, + country_code: stop_point.country_code, + country_name: stop_point.country_name, + object_id: stop_point.object_id + "-2" + } + }) + + set('other_country_stop_point', () => { + return { + name: "Antother stop point", + city_name: "New York", + zip_code: "232323", + country_code: "US", + country_name: "USA", + object_id: "sp-USA" + } + }) + it('should display the city name', () => { + expect(component).toMatchSnapshot() + }) + context('with the "long_distance_routes" feature', () => { + set('features', () => { + return { long_distance_routes: true } + }) + it('should display the country name', () => { + expect(component).toMatchSnapshot() + }) + }) +}) diff --git a/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap new file mode 100644 index 000000000..90b8cb656 --- /dev/null +++ b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap @@ -0,0 +1,169 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`stopPointHeader should display the city name 1`] = ` +
+
+
+
+
+
+ ID Mission +
+
+ Code mission +
+
+ Nb arrĂȘts +
+
+
+
+ + + Stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+
+
+
+
+
+`; + +exports[`stopPointHeader with the "long_distance_routes" feature should display the country name 1`] = ` +
+
+
+
+
+
+ ID Mission +
+
+ Code mission +
+
+ Nb arrĂȘts +
+
+
+
+ + + Stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+
+
+
+
+
+`; diff --git a/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js b/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js index 17e9579d2..87151c64b 100644 --- a/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js +++ b/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js @@ -40,7 +40,8 @@ describe('stopPointHeader', () => { city_name: "City Name", zip_code: "12345", country_code: "FR", - country_name: "france" + country_name: "france", + object_id: "sp-FR" } }) @@ -50,7 +51,8 @@ describe('stopPointHeader', () => { city_name: stop_point.city_name, zip_code: stop_point.zip_code, country_code: stop_point.country_code, - country_name: stop_point.country_name + country_name: stop_point.country_name, + object_id: stop_point.object_id + "-2" } }) @@ -60,7 +62,8 @@ describe('stopPointHeader', () => { city_name: "New York", zip_code: "232323", country_code: "US", - country_name: "USA" + country_name: "USA", + object_id: "sp-USA" } }) it('should display the city name', () => { diff --git a/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap b/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap index 0af57e586..703f727d7 100644 --- a/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap +++ b/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap @@ -21,9 +21,15 @@ exports[`stopPointHeader should display the city name 1`] = ` > ID course
+
+ Nom course +
ID mission
+
+ Transporteur +
Calendriers
@@ -105,9 +111,15 @@ exports[`stopPointHeader with the "long_distance_routes" feature should display > ID course
+
+ Nom course +
ID mission
+
+ Transporteur +
Calendriers
-- cgit v1.2.3