-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from mapbox/handle-errors
Handle errors
- Loading branch information
Showing
10 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class='directions-control directions-control-directions'> | ||
<div class='mapbox-directions-error'> | ||
<%= error %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const once = require('lodash.once'); | ||
const test = require('tape'); | ||
|
||
test('Directions#instructionControl', tt => { | ||
let container, map, directions; | ||
|
||
function setup(opts) { | ||
container = document.createElement('div'); | ||
map = new mapboxgl.Map({ container: container }); | ||
directions = mapboxgl.Directions(opts); | ||
map.addControl(directions); | ||
} | ||
|
||
tt.test('displayed', t => { | ||
setup(); | ||
t.plan(2); | ||
directions.setOrigin([-79, 43]); | ||
directions.setDestination([-77, 41]); | ||
directions.on('directions.route', once((e) => { | ||
t.ok(e.route, 'route is emitted'); | ||
t.ok(container.querySelector('.directions-control-directions').textContent, 'instructions are shown'); | ||
})); | ||
}); | ||
|
||
tt.test('error', t => { | ||
setup(); | ||
t.plan(1); | ||
directions.setOrigin('Montreal Quebec'); | ||
directions.setDestination('Toledo Spain'); | ||
directions.on('directions.error', once((e) => { | ||
t.ok(e.error, 'error is emitted'); | ||
})); | ||
}); | ||
|
||
tt.end(); | ||
}); | ||
|