-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale update units #6138
Scale update units #6138
Changes from 5 commits
9749515
64e9140
914c57e
15fbbed
6d7b572
80f2791
ff9c13f
fb650c2
f8bc7b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
const test = require('mapbox-gl-js-test').test; | ||
const window = require('../../../../src/util/window'); | ||
const Map = require('../../../../src/ui/map'); | ||
const ScaleControl = require('../../../../src/ui/control/scale_control'); | ||
|
||
function createMap() { | ||
const container = window.document.createElement('div'); | ||
return new Map({ | ||
container, | ||
style: { | ||
version: 8, | ||
sources: {}, | ||
layers: [] | ||
}, | ||
hash: true | ||
}); | ||
|
||
} | ||
|
||
test('ScaleControl appears in bottom-left by default', (t) => { | ||
const map = createMap(); | ||
map.addControl(new ScaleControl()); | ||
|
||
t.equal(map.getContainer().querySelectorAll('.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-scale').length, 1); | ||
t.end(); | ||
}); | ||
|
||
test('ScaleControl appears in the position specified by the position option', (t) => { | ||
const map = createMap(); | ||
map.addControl(new ScaleControl(), 'top-left'); | ||
|
||
t.equal(map.getContainer().querySelectorAll('.mapboxgl-ctrl-top-left .mapboxgl-ctrl-scale').length, 1); | ||
t.end(); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙇 thank you for adding these tests! Could you also add one that tests the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @anandthakker I will work on this in the next day or so. Thanks for the feedback. |
||
|
||
test('ScaleControl should change unit of distance after calling setUnit', (t) => { | ||
const map = createMap(); | ||
const scale = new ScaleControl(); | ||
map.addControl(scale); | ||
|
||
t.equal(scale.options.unit, 'metric'); | ||
scale.setUnit('imperial'); | ||
t.equal(scale.options.unit, 'imperial'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that the unit is stored in |
||
t.end(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String
is causing the CI to fail, I believe it should bestring
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think it would be helpful to include the documentation for
unit
, listing out what the supported values are.