Skip to content

Commit

Permalink
Added silent test case
Browse files Browse the repository at this point in the history
  • Loading branch information
underoot committed Dec 2, 2024
1 parent c13b9bc commit 34d751f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/interaction_events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,66 @@ test('ensure user interactions fire right events', async (t) => {
});
});

test('Ensure API is silent by default', async () => {
const container = document.createElement('div');
document.body.appendChild(container);
const map = createMap({ container });
const fireSpy = spy(map, 'fire');
const Draw = new MapboxDraw();

map.addControl(Draw);
await map.on('load');

fireSpy.resetHistory();

document.body.removeChild(container);

Draw.changeMode('draw_point');

assert(fireSpy.args.find(arg => arg[0].startsWith('draw.modechange')) === undefined, 'no mode change event fired');

Draw.add({
type: 'Feature',
id: 'point',
properties: {},
geometry: {
type: 'Point',
coordinates: [10, 10]
}
});

fireSpy.resetHistory();

Draw.delete('point');
Draw.add({
type: 'Feature',
id: 'line',
properties: {},
geometry: {
type: 'LineString',
coordinates: [[10, 10], [20, 20]]
}
});
Draw.deleteAll();

Draw.set({
type: 'FeatureCollection',
features: [{
type: 'Feature',
id: 'point',
properties: {},
geometry: {
type: 'Point',
coordinates: [10, 10]
}
}]
});

Draw.setFeatureProperty('point', 'price', 200);

assert.equal(fireSpy.callCount, 0, 'no draw events fired');
});

test('ensure API fire right events', async (t) => {
const container = document.createElement('div');
document.body.appendChild(container);
Expand Down

0 comments on commit 34d751f

Please sign in to comment.