Skip to content

Commit da2608f

Browse files
committed
fix(test): fix test condition so that trip plans on load URL with search
1 parent 92eb991 commit da2608f

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lib/actions/api.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import moment from 'moment'
66
import haversine from 'haversine'
77

88
import { rememberPlace } from './map'
9-
import { queryIsValid } from '../util/state'
10-
import queryParams from '../util/query-params'
11-
import { getTripOptionsFromQuery, getUrlParams } from '../util/query'
129
import { hasCar } from '../util/itinerary'
10+
import { getTripOptionsFromQuery, getUrlParams } from '../util/query'
11+
import queryParams from '../util/query-params'
12+
import { queryIsValid } from '../util/state'
13+
import { randId } from '../util/storage'
1314
if (typeof (fetch) === 'undefined') require('isomorphic-fetch')
1415

1516
// Generic API actions
@@ -22,14 +23,6 @@ export const toggleTracking = createAction('TOGGLE_TRACKING')
2223
export const rememberSearch = createAction('REMEMBER_SEARCH')
2324
export const forgetSearch = createAction('FORGET_SEARCH')
2425

25-
/**
26-
* Generate a random ID. This might not quite be a UUID, but it serves our
27-
* purposes for now.
28-
*/
29-
function randId () {
30-
return Math.random().toString(36).substr(2, 9)
31-
}
32-
3326
function formatRecentPlace (place) {
3427
return {
3528
...place,

lib/actions/form.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
getUrlParams,
1010
planParamsToQuery
1111
} from '../util/query'
12-
import { getItem } from '../util/storage'
12+
import { getItem, randId } from '../util/storage'
1313
import { queryIsValid } from '../util/state'
1414
import { isMobile } from '../util/ui'
1515
import {
@@ -65,8 +65,7 @@ export function parseUrlQueryString (params = getUrlParams()) {
6565
Object.keys(params).forEach(key => {
6666
if (!key.startsWith('ui_')) planParams[key] = params[key]
6767
})
68-
const searchId = params.ui_activeSearch
69-
console.log(params, searchId)
68+
const searchId = params.ui_activeSearch || randId()
7069
// Convert strings to numbers/objects and dispatch
7170
dispatch(setQueryParam(planParamsToQuery(planParams), searchId))
7271
}

lib/util/storage.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ export function getItem (key, notFoundValue = null) {
3232
export function removeItem (key) {
3333
window.localStorage.removeItem(`${STORAGE_PREFIX}.${key}`)
3434
}
35+
36+
/**
37+
* Generate a random ID. This might not quite be a UUID, but it serves our
38+
* purposes for now.
39+
*/
40+
export function randId () {
41+
return Math.random().toString(36).substr(2, 9)
42+
}

0 commit comments

Comments
 (0)