diff --git a/test/unit/ui_utils_spec.js b/test/unit/ui_utils_spec.js index 4ba2a22e0..eab665fe1 100644 --- a/test/unit/ui_utils_spec.js +++ b/test/unit/ui_utils_spec.js @@ -272,13 +272,17 @@ describe('ui_utils', function() { eventBus.on('test', function() { count++; }); - document.addEventListener('test', function() { - count++; - }); + function domEventListener() { + done.fail('shall not dispatch DOM event.'); + } + document.addEventListener('test', domEventListener); + eventBus.dispatch('test'); Promise.resolve().then(() => { expect(count).toEqual(1); + + document.removeEventListener('test', domEventListener); done(); }); }); @@ -291,13 +295,17 @@ describe('ui_utils', function() { eventBus.on('test', function() { count++; }); - document.addEventListener('test', function() { + function domEventListener() { count++; - }); + } + document.addEventListener('test', domEventListener); + eventBus.dispatch('test'); Promise.resolve().then(() => { expect(count).toEqual(2); + + document.removeEventListener('test', domEventListener); done(); }); });