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