diff --git a/src/ui/public/notify/__tests__/notifier.js b/src/ui/public/notify/__tests__/notifier.js index 2fd0a7fbe7e6d..223536d6bb635 100644 --- a/src/ui/public/notify/__tests__/notifier.js +++ b/src/ui/public/notify/__tests__/notifier.js @@ -33,10 +33,13 @@ describe('Notifier', function () { beforeEach(function () { params = { location: 'foo' }; - while (Notifier.prototype._notifs.pop()); // clear global notifications notifier = new Notifier(params); }); + afterEach(function () { + Notifier.prototype._notifs.length = 0; + }); + describe('#constructor()', function () { it('sets #from from given location', function () { expect(notifier.from).to.equal(params.location); @@ -465,13 +468,12 @@ describe('Directive Notification', function () { scope; }); - while (Notifier.prototype._notifs.pop()); // clear global notifications - notifier = new Notifier({ location: 'directiveFoo' }); directiveNotification = notifier.directive(directiveParam, customParams); }); afterEach(() => { + Notifier.prototype._notifs.length = 0; directiveNotification.clear(); scope.$destroy(); }); diff --git a/src/ui/public/route_based_notifier/__tests__/index.js b/src/ui/public/route_based_notifier/__tests__/index.js index 20e26b1227a4f..24916b8018477 100644 --- a/src/ui/public/route_based_notifier/__tests__/index.js +++ b/src/ui/public/route_based_notifier/__tests__/index.js @@ -10,12 +10,15 @@ describe('ui/route_based_notifier', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(($injector) => { - remove(Notifier.prototype._notifs); // hack to reset the global notification array const Private = $injector.get('Private'); routeBasedNotifier = Private(routeBasedNotifierProvider); $rootScope = $injector.get('$rootScope'); })); + afterEach(() => { + Notifier.prototype._notifs.length = 0; + }); + describe('#warning()', () => { it('adds a warning notification', () => { routeBasedNotifier.warning('wat'); diff --git a/src/ui/public/test_harness/test_harness.js b/src/ui/public/test_harness/test_harness.js index 3c1cba2ea0327..8d0c6cef87878 100644 --- a/src/ui/public/test_harness/test_harness.js +++ b/src/ui/public/test_harness/test_harness.js @@ -6,6 +6,7 @@ import chrome from 'ui/chrome'; import Nonsense from 'Nonsense'; import sinon from 'sinon'; import _ from 'lodash'; +import Notifier from 'ui/notify/notifier'; import StackTraceMapper from 'ui/stack_trace_mapper'; import { parse } from 'url'; @@ -55,6 +56,13 @@ before(function () { sinon.useFakeXMLHttpRequest(); }); +beforeEach(function () { + if (Notifier.prototype._notifs.length) { + Notifier.prototype._notifs.length = 0; + throw new Error('notifications were left in the notifier'); + } +}); + /*** Kick off mocha, called at the end of test entry files ***/ exports.bootstrap = function () {