Skip to content

Commit

Permalink
Update map tests to use numerical indices
Browse files Browse the repository at this point in the history
  • Loading branch information
bfrengley authored and Asheem Mamoowala committed Aug 16, 2018
1 parent 91173dc commit 696a50a
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions test/unit/ui/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,8 @@ test('Map', (t) => {
}
});
map.on('load', () => {
map.setFeatureState({ source: 'geojson', id: '12345'}, {'hover': true});
const fState = map.getFeatureState({ source: 'geojson', id: '12345'});
map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true});
const fState = map.getFeatureState({ source: 'geojson', id: 12345});
t.equal(fState.hover, true);
t.end();
});
Expand Down Expand Up @@ -1311,7 +1311,7 @@ test('Map', (t) => {
}
});
t.throws(() => {
map.setFeatureState({ source: 'geojson', id: '12345'}, {'hover': true});
map.setFeatureState({ source: 'geojson', id: 12345}, {'hover': true});
}, Error, /load/i);

t.end();
Expand All @@ -1331,7 +1331,7 @@ test('Map', (t) => {
t.match(error.message, /source/);
t.end();
});
map.setFeatureState({ source: 'vector', id: '12345'}, {'hover': true});
map.setFeatureState({ source: 'vector', id: 12345}, {'hover': true});
});
});
t.test('fires an error if sourceLayer not provided for a vector source', (t) => {
Expand All @@ -1352,7 +1352,7 @@ test('Map', (t) => {
t.match(error.message, /sourceLayer/);
t.end();
});
map.setFeatureState({ source: 'vector', sourceLayer: 0, id: '12345'}, {'hover': true});
map.setFeatureState({ source: 'vector', sourceLayer: 0, id: 12345}, {'hover': true});
});
});
t.test('fires an error if id not provided', (t) => {
Expand All @@ -1376,6 +1376,27 @@ test('Map', (t) => {
map.setFeatureState({ source: 'vector', sourceLayer: "1"}, {'hover': true});
});
});
t.test('fires an error if id is less than zero', (t) => {
const map = createMap(t, {
style: {
"version": 8,
"sources": {
"vector": {
"type": "vector",
"tiles": ["http://example.com/{z}/{x}/{y}.png"]
}
},
"layers": []
}
});
map.on('load', () => {
map.on('error', ({ error }) => {
t.match(error.message, /id/);
t.end();
});
map.setFeatureState({ source: 'vector', sourceLayer: "1", id: -1}, {'hover': true});
});
});
t.end();
});

Expand Down

0 comments on commit 696a50a

Please sign in to comment.