diff --git a/test/interaction_events.test.js b/test/interaction_events.test.js index 5752b14ab..fc0ec055f 100644 --- a/test/interaction_events.test.js +++ b/test/interaction_events.test.js @@ -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);