Test empty string rendering for mouse control

This commit is contained in:
Tim Schaub
2021-07-09 14:44:09 -06:00
parent bfe5afe069
commit 9e7f5a9b40

View File

@@ -105,9 +105,9 @@ describe('ol/control/MousePosition', function () {
expect(element.innerHTML).to.be(' ');
});
it('retains the mouse position when undefinedHTML is falsey and mouse moves outside the viewport', function () {
it('retains the mouse position when undefinedHTML is false and mouse moves outside the viewport', function () {
const ctrl = new MousePosition({
undefinedHTML: '',
undefinedHTML: false,
});
ctrl.setMap(map);
map.renderSync();
@@ -127,6 +127,29 @@ describe('ol/control/MousePosition', function () {
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
expect(element.innerHTML).to.be('20,-30');
});
it('renders an empty string if undefinedHTML is an empty string and mouse moves outside the viewport', function () {
const ctrl = new MousePosition({
undefinedHTML: '',
});
ctrl.setMap(map);
map.renderSync();
const element = document.querySelector(
'.ol-mouse-position',
map.getTarget()
);
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
expect(element.innerHTML).to.be('');
target.dispatchEvent(new PointerEvent('pointermove'));
simulateEvent(EventType.POINTERMOVE, 20, 30);
expect(element.innerHTML).to.be('20,-30');
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
expect(element.innerHTML).to.be('');
});
});
});
});