aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascript/vehicle_journeys/components/VehicleJourneys_spec.js
blob: 38e4f17a72b5f074848d0610c40d58a19086c904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React, { Component } from 'react'
import VehicleJourneys from '../../../../app/javascript/vehicle_journeys/components/VehicleJourneys'
import renderer from 'react-test-renderer'

import I18n from '../../support/jest-i18n'

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: [],
			customFields: {},
			extraHeaders: []
    }
    let list = renderer.create(
      <VehicleJourneys
        status={props.status}
        filters={props.filters}
        onLoadFirstPage={props.onLoadFirstPage}
        onUpdateTime={props.onUpdateTime}
        onSelectVehicleJourney={props.onSelectVehicleJourney}
        stopPointsList={props.stopPointsList}
        vehicleJourneys={props.vehicleJourneys}
				customFields={props.customFields}
        extraHeaders={props.extraHeaders}
      />
    ).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()
    })
  })
})