Skip to content

Commit 562fc08

Browse files
authored
Merge pull request #66 from opentripplanner/dev
Next release
2 parents 98f71a9 + 42ddb83 commit 562fc08

File tree

103 files changed

+7094
-2855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+7094
-2855
lines changed

Diff for: .travis.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@ notifications:
55
email: false
66
webhooks: https://outlook.office.com/webhook/03fa4a79-572f-4c68-b756-e4e851d0215a@9093f1a3-8771-4fb7-8596-d51eeef18cda/TravisCI/449087910d3647598cf3d7c6387fb8fc/286c079f-6085-4aa0-8f8d-e2a3e8d1f568
77
node_js:
8-
- '8'
9-
before_install:
10-
- npm i -g yarn codecov
8+
- '12' # mastarm 5 requires node.js 10 or greater
119
after_success:
10+
- bash <(curl -s https://codecov.io/bash)
1211
- semantic-release
13-
before_script:
14-
- yarn global add codecov
1512
script:
1613
- yarn run lint
1714
- yarn run lint-docs
1815
- yarn run cover
1916
- yarn run build
20-
- codecov
2117
branches:
2218
except:
2319
- /^v\d+\.\d+\.\d+$/

Diff for: __tests__/actions/__snapshots__/api.js.snap

+23-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@ Array [
55
Array [
66
Object {
77
"payload": Object {
8+
"activeItinerary": 0,
89
"routingType": "ITINERARY",
9-
"searchId": 2,
10+
"searchId": "abcd1234",
1011
},
1112
"type": "ROUTING_REQUEST",
1213
},
1314
],
15+
Array [
16+
[Function],
17+
],
18+
Array [
19+
Object {
20+
"payload": Object {
21+
"activeItinerary": 0,
22+
"routingType": "ITINERARY",
23+
"searchId": "abcd1235",
24+
},
25+
"type": "ROUTING_REQUEST",
26+
},
27+
],
28+
Array [
29+
[Function],
30+
],
1431
]
1532
`;
1633

@@ -19,12 +36,16 @@ Array [
1936
Array [
2037
Object {
2138
"payload": Object {
39+
"activeItinerary": 0,
2240
"routingType": "ITINERARY",
23-
"searchId": 1,
41+
"searchId": "abcd1234",
2442
},
2543
"type": "ROUTING_REQUEST",
2644
},
2745
],
46+
Array [
47+
[Function],
48+
],
2849
]
2950
`;
3051

Diff for: __tests__/actions/api.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import nock from 'nock'
44

5-
import {routingQuery} from '../../lib/actions/api'
5+
import * as api from '../../lib/actions/api'
6+
7+
// Use mocked randId function and pass in searchId for routingQuery calls so that
8+
// snapshots are deterministic (i.e., the random IDs don't change).
9+
let idCounter = 1234
10+
const randId = () => `abcd${idCounter++}`
611

712
describe('actions > api', () => {
813
describe('routingQuery', () => {
@@ -24,9 +29,12 @@ describe('actions > api', () => {
2429
searches: []
2530
}
2631
}
32+
// Create mock functions for dispatch and getState used for thunk actions.
33+
const mockDispatch = jest.fn()
34+
const mockGetState = () => defaultState
2735

2836
it('should make a query to OTP', async () => {
29-
const routingQueryAction = routingQuery()
37+
const routingQueryAction = api.routingQuery(randId())
3038

3139
nock('http://mock-host.com')
3240
.get(/api\/plan/)
@@ -35,27 +43,19 @@ describe('actions > api', () => {
3543
return { fake: 'response' }
3644
})
3745

38-
const mockDispatch = jest.fn()
39-
await routingQueryAction(mockDispatch, () => {
40-
return defaultState
41-
})
42-
46+
await routingQueryAction(mockDispatch, mockGetState)
4347
expect(mockDispatch.mock.calls).toMatchSnapshot()
4448
})
4549

4650
it('should gracefully handle bad response', async () => {
47-
const routingQueryAction = routingQuery()
51+
const routingQueryAction = api.routingQuery(randId())
4852

4953
nock('http://mock-host.com')
5054
.get(/api\/plan/)
5155
.reply(500, {
5256
fake: 'response'
5357
})
54-
55-
const mockDispatch = jest.fn()
56-
await routingQueryAction(mockDispatch, () => {
57-
return defaultState
58-
})
58+
await routingQueryAction(mockDispatch, mockGetState)
5959

6060
expect(mockDispatch.mock.calls).toMatchSnapshot()
6161
})

Diff for: __tests__/actions/form.js_hold

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// FIXME: This file has been renamed because formChanged is no longer
2+
// triggering debounces. See https://github.com/opentripplanner/otp-react-redux/pull/62#discussion_r298272504
3+
// NOTE: Commenting out the entire test file causes a failure because at least
4+
// one test must be run per test file.
5+
// TODO: write tests for form actions
6+
7+
/* globals describe, expect, it, jest */
8+
9+
import { timeoutPromise } from '../test-utils'
10+
11+
import { formChanged } from '../../lib/actions/form'
12+
13+
describe('actions > api > form', () => {
14+
it('should debounce numerous requests to plan a trip', async () => {
15+
const queries = [
16+
// Query 1
17+
{
18+
from: { lat: 12, lon: 34 },
19+
to: { lat: 34, lon: 12 }
20+
},
21+
// Query 2 (from location changed)
22+
{
23+
from: { lat: 11, lon: 33 },
24+
to: { lat: 34, lon: 12 }
25+
}
26+
]
27+
const defaultState = {
28+
otp: {
29+
config: {
30+
api: {
31+
host: 'http://mock-host.com',
32+
path: '/api',
33+
port: 80
34+
},
35+
autoPlan: true,
36+
debouncePlanTimeMs: 500
37+
},
38+
currentQuery: queries[0],
39+
searches: []
40+
}
41+
}
42+
43+
const mockDispatch = jest.fn()
44+
for (var i = 0; i < 10; i++) {
45+
// Alternate back and forth between two queries on each iteration.
46+
const formChangedAction = formChanged(queries[i % 2], queries[(i + 1) % 2])
47+
formChangedAction(mockDispatch, () => defaultState)
48+
}
49+
50+
// wait for request to complete
51+
await timeoutPromise(1000)
52+
53+
expect(mockDispatch.mock.calls).toMatchSnapshot()
54+
})
55+
})

Diff for: __tests__/actions/form.js_old

-43
This file was deleted.

Diff for: example-config.yml

+41-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
api:
2-
host: http://trimet.dev.conveyal.com
2+
host: http://localhost
33
path: /otp/routers/default
44
port: 8001
55

@@ -8,8 +8,10 @@ map:
88
initLon: -122.682
99
baseLayers:
1010
- name: Streets
11-
url: http://tile.stamen.com/terrain/{z}/{x}/{y}.png
12-
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
11+
url: //cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png
12+
subdomains: 'abcd'
13+
attribution: 'Map tiles: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>'
14+
maxZoom: 20
1315
- name: Stamen Toner Lite
1416
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
1517
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
@@ -28,12 +30,39 @@ geocoder:
2830
# Optional custom Pelias instance (defaults to Mapzen Search)
2931
# baseUrl: https://geocoder.example.com/pelias/v1
3032

31-
modeGroups:
32-
- name: Transit
33-
modes:
34-
- TRAM
35-
- BUS
36-
- name: Walk/Bike
37-
modes:
38-
- WALK
39-
- BICYCLE
33+
# Use this mode config for the enhanced Transit+ config
34+
modes:
35+
transitModes:
36+
- mode: BUS
37+
label: Bus
38+
- mode: TRAM
39+
label: MAX & Streetcar
40+
- mode: RAIL
41+
label: WES
42+
- mode: GONDOLA
43+
label: Aerial Tram
44+
45+
accessModes:
46+
- mode: BICYCLE
47+
label: Transit + Bike
48+
49+
bicycleModes:
50+
- mode: BICYCLE
51+
label: Own Bike
52+
iconWidth: 18
53+
54+
55+
routingTypes:
56+
- key: ITINERARY
57+
text: Exact Time
58+
59+
### Use this config for the standard mode selector
60+
# modeGroups:
61+
# - name: Transit
62+
# modes:
63+
# - TRAM
64+
# - BUS
65+
# - name: Walk/Bike
66+
# modes:
67+
# - WALK
68+
# - BICYCLE

0 commit comments

Comments
 (0)