Skip to content

Commit

Permalink
Merge pull request #66 from opentripplanner/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
landonreed authored Jun 28, 2019
2 parents 98f71a9 + 42ddb83 commit 562fc08
Show file tree
Hide file tree
Showing 103 changed files with 7,094 additions and 2,855 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ notifications:
email: false
webhooks: https://outlook.office.com/webhook/03fa4a79-572f-4c68-b756-e4e851d0215a@9093f1a3-8771-4fb7-8596-d51eeef18cda/TravisCI/449087910d3647598cf3d7c6387fb8fc/286c079f-6085-4aa0-8f8d-e2a3e8d1f568
node_js:
- '8'
before_install:
- npm i -g yarn codecov
- '12' # mastarm 5 requires node.js 10 or greater
after_success:
- bash <(curl -s https://codecov.io/bash)
- semantic-release
before_script:
- yarn global add codecov
script:
- yarn run lint
- yarn run lint-docs
- yarn run cover
- yarn run build
- codecov
branches:
except:
- /^v\d+\.\d+\.\d+$/
25 changes: 23 additions & 2 deletions __tests__/actions/__snapshots__/api.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ Array [
Array [
Object {
"payload": Object {
"activeItinerary": 0,
"routingType": "ITINERARY",
"searchId": 2,
"searchId": "abcd1234",
},
"type": "ROUTING_REQUEST",
},
],
Array [
[Function],
],
Array [
Object {
"payload": Object {
"activeItinerary": 0,
"routingType": "ITINERARY",
"searchId": "abcd1235",
},
"type": "ROUTING_REQUEST",
},
],
Array [
[Function],
],
]
`;

Expand All @@ -19,12 +36,16 @@ Array [
Array [
Object {
"payload": Object {
"activeItinerary": 0,
"routingType": "ITINERARY",
"searchId": 1,
"searchId": "abcd1234",
},
"type": "ROUTING_REQUEST",
},
],
Array [
[Function],
],
]
`;

Expand Down
26 changes: 13 additions & 13 deletions __tests__/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import nock from 'nock'

import {routingQuery} from '../../lib/actions/api'
import * as api from '../../lib/actions/api'

// Use mocked randId function and pass in searchId for routingQuery calls so that
// snapshots are deterministic (i.e., the random IDs don't change).
let idCounter = 1234
const randId = () => `abcd${idCounter++}`

describe('actions > api', () => {
describe('routingQuery', () => {
Expand All @@ -24,9 +29,12 @@ describe('actions > api', () => {
searches: []
}
}
// Create mock functions for dispatch and getState used for thunk actions.
const mockDispatch = jest.fn()
const mockGetState = () => defaultState

it('should make a query to OTP', async () => {
const routingQueryAction = routingQuery()
const routingQueryAction = api.routingQuery(randId())

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

const mockDispatch = jest.fn()
await routingQueryAction(mockDispatch, () => {
return defaultState
})

await routingQueryAction(mockDispatch, mockGetState)
expect(mockDispatch.mock.calls).toMatchSnapshot()
})

it('should gracefully handle bad response', async () => {
const routingQueryAction = routingQuery()
const routingQueryAction = api.routingQuery(randId())

nock('http://mock-host.com')
.get(/api\/plan/)
.reply(500, {
fake: 'response'
})

const mockDispatch = jest.fn()
await routingQueryAction(mockDispatch, () => {
return defaultState
})
await routingQueryAction(mockDispatch, mockGetState)

expect(mockDispatch.mock.calls).toMatchSnapshot()
})
Expand Down
55 changes: 55 additions & 0 deletions __tests__/actions/form.js_hold
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// FIXME: This file has been renamed because formChanged is no longer
// triggering debounces. See https://github.com/opentripplanner/otp-react-redux/pull/62#discussion_r298272504
// NOTE: Commenting out the entire test file causes a failure because at least
// one test must be run per test file.
// TODO: write tests for form actions

/* globals describe, expect, it, jest */

import { timeoutPromise } from '../test-utils'

import { formChanged } from '../../lib/actions/form'

describe('actions > api > form', () => {
it('should debounce numerous requests to plan a trip', async () => {
const queries = [
// Query 1
{
from: { lat: 12, lon: 34 },
to: { lat: 34, lon: 12 }
},
// Query 2 (from location changed)
{
from: { lat: 11, lon: 33 },
to: { lat: 34, lon: 12 }
}
]
const defaultState = {
otp: {
config: {
api: {
host: 'http://mock-host.com',
path: '/api',
port: 80
},
autoPlan: true,
debouncePlanTimeMs: 500
},
currentQuery: queries[0],
searches: []
}
}

const mockDispatch = jest.fn()
for (var i = 0; i < 10; i++) {
// Alternate back and forth between two queries on each iteration.
const formChangedAction = formChanged(queries[i % 2], queries[(i + 1) % 2])
formChangedAction(mockDispatch, () => defaultState)
}

// wait for request to complete
await timeoutPromise(1000)

expect(mockDispatch.mock.calls).toMatchSnapshot()
})
})
43 changes: 0 additions & 43 deletions __tests__/actions/form.js_old

This file was deleted.

53 changes: 41 additions & 12 deletions example-config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
api:
host: http://trimet.dev.conveyal.com
host: http://localhost
path: /otp/routers/default
port: 8001

Expand All @@ -8,8 +8,10 @@ map:
initLon: -122.682
baseLayers:
- name: Streets
url: http://tile.stamen.com/terrain/{z}/{x}/{y}.png
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>.'
url: //cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png
subdomains: 'abcd'
attribution: 'Map tiles: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>'
maxZoom: 20
- name: Stamen Toner Lite
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
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>.'
Expand All @@ -28,12 +30,39 @@ geocoder:
# Optional custom Pelias instance (defaults to Mapzen Search)
# baseUrl: https://geocoder.example.com/pelias/v1

modeGroups:
- name: Transit
modes:
- TRAM
- BUS
- name: Walk/Bike
modes:
- WALK
- BICYCLE
# Use this mode config for the enhanced Transit+ config
modes:
transitModes:
- mode: BUS
label: Bus
- mode: TRAM
label: MAX & Streetcar
- mode: RAIL
label: WES
- mode: GONDOLA
label: Aerial Tram

accessModes:
- mode: BICYCLE
label: Transit + Bike

bicycleModes:
- mode: BICYCLE
label: Own Bike
iconWidth: 18


routingTypes:
- key: ITINERARY
text: Exact Time

### Use this config for the standard mode selector
# modeGroups:
# - name: Transit
# modes:
# - TRAM
# - BUS
# - name: Walk/Bike
# modes:
# - WALK
# - BICYCLE
Loading

0 comments on commit 562fc08

Please sign in to comment.