diff options
Diffstat (limited to 'spec')
4 files changed, 264 insertions, 3 deletions
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( + <JourneyPatterns + status={props.status} + journeyPatterns={props.journeyPatterns} + stopPointsList={props.stopPointsList} + onCheckboxChange={props.onCheckboxChange} + onLoadFirstPage={props.onLoadFirstPage} + onOpenEditModal={props.onOpenEditModal} + /> + ).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`] = ` +<div + className="row" +> + <div + className="col-lg-12" + > + <div + className="table table-2entries mt-sm mb-sm no_result" + > + <div + className="t2e-head w20" + > + <div + className="th" + > + <div + className="strong mb-xs" + > + ID Mission + </div> + <div> + Code mission + </div> + <div> + Nb arrĂȘts + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="City Name" + title="City Name (12345)" + > + <span> + <span> + Stop point + </span> + </span> + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="City Name" + title="City Name (12345)" + > + <span> + <span> + Antother stop point + </span> + </span> + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="City Name" + title="New York (232323)" + > + <span> + <span> + Antother stop point + </span> + </span> + </div> + </div> + </div> + <div + className="t2e-item-list w80" + > + <div /> + </div> + </div> + </div> +</div> +`; + +exports[`stopPointHeader with the "long_distance_routes" feature should display the country name 1`] = ` +<div + className="row" +> + <div + className="col-lg-12" + > + <div + className="table table-2entries mt-sm mb-sm no_result" + > + <div + className="t2e-head w20" + > + <div + className="th" + > + <div + className="strong mb-xs" + > + ID Mission + </div> + <div> + Code mission + </div> + <div> + Nb arrĂȘts + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="france" + title="City Name (12345)" + > + <span> + <span> + Stop point + </span> + </span> + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="france" + title="City Name (12345)" + > + <span> + <span> + Antother stop point + </span> + </span> + </div> + </div> + <div + className="td" + > + <div + className="headlined" + data-headline="france" + title="New York (232323)" + > + <span> + <span> + Antother stop point + </span> + </span> + </div> + </div> + </div> + <div + className="t2e-item-list w80" + > + <div /> + </div> + </div> + </div> +</div> +`; 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 @@ -22,9 +22,15 @@ exports[`stopPointHeader should display the city name 1`] = ` ID course </div> <div> + Nom course + </div> + <div> ID mission </div> <div> + Transporteur + </div> + <div> Calendriers </div> </div> @@ -106,9 +112,15 @@ exports[`stopPointHeader with the "long_distance_routes" feature should display ID course </div> <div> + Nom course + </div> + <div> ID mission </div> <div> + Transporteur + </div> + <div> Calendriers </div> </div> |
