Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ui/public/notify/__tests__/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
});
Expand Down
5 changes: 4 additions & 1 deletion src/ui/public/route_based_notifier/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 8 additions & 0 deletions src/ui/public/test_harness/test_harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 () {
Expand Down