From 3bc583b1e727f0cf27e0aef8ef94121dd693cd86 Mon Sep 17 00:00:00 2001 From: Zog Date: Thu, 28 Dec 2017 17:07:37 +0100 Subject: Refs #5437 @0.5h; Show country name instead of city in the journeys editor When the organisation has the "long_distance_routes" features. Mind the `StopArea#country_name` method which is pending until we merge the branch which adds the countries support. --- .../components/VehicleJourneys_spec.js | 77 ++++++++++ .../__snapshots__/VehicleJourneys_spec.js.snap | 169 +++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js create mode 100644 spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap (limited to 'spec/javascript') diff --git a/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js b/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js new file mode 100644 index 000000000..17e9579d2 --- /dev/null +++ b/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js @@ -0,0 +1,77 @@ +import React, { Component } from 'react' +import VehicleJourneys from '../../../../app/javascript/vehicle_journeys/components/VehicleJourneys' +import renderer from 'react-test-renderer' + +describe('stopPointHeader', () => { + set('features', () => { + return {} + }) + set('component', () => { + let props = { + status: {}, + filters: { + permissions: {}, + features: features + }, + onLoadFirstPage: ()=>{}, + onUpdateTime: ()=>{}, + onSelectVehicleJourney: ()=>{}, + stopPointsList: [stop_point, same_city_stop_point, other_country_stop_point], + vehicleJourneys: [] + } + 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" + } + }) + + 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 + } + }) + + set('other_country_stop_point', () => { + return { + name: "Antother stop point", + city_name: "New York", + zip_code: "232323", + country_code: "US", + country_name: "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/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap b/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap new file mode 100644 index 000000000..0af57e586 --- /dev/null +++ b/spec/javascript/vehicle_journeys/components/__snapshots__/VehicleJourneys_spec.js.snap @@ -0,0 +1,169 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`stopPointHeader should display the city name 1`] = ` +
+
+
+
+
+
+ ID course +
+
+ ID mission +
+
+ Calendriers +
+
+
+
+ + + Stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+
+
+
+
+
+`; + +exports[`stopPointHeader with the "long_distance_routes" feature should display the country name 1`] = ` +
+
+
+
+
+
+ ID course +
+
+ ID mission +
+
+ Calendriers +
+
+
+
+ + + Stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+ + + Antother stop point + + +
+
+
+
+
+
+
+
+
+`; -- cgit v1.2.3 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 From aaa9ee2fabe87209df028bb225339108bf389f64 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 10 Jan 2018 10:47:23 +0100 Subject: Refs #5437 @1h; Refactor code --- .../components/__snapshots__/JourneyPatterns_spec.js.snap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spec/javascript') diff --git a/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap index 90b8cb656..a332e7d80 100644 --- a/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap +++ b/spec/javascript/journey_patterns/components/__snapshots__/JourneyPatterns_spec.js.snap @@ -47,8 +47,8 @@ exports[`stopPointHeader should display the city name 1`] = ` className="td" >
@@ -63,7 +63,7 @@ exports[`stopPointHeader should display the city name 1`] = ` >
@@ -131,8 +131,8 @@ exports[`stopPointHeader with the "long_distance_routes" feature should display className="td" >
@@ -147,7 +147,7 @@ exports[`stopPointHeader with the "long_distance_routes" feature should display >
-- cgit v1.2.3