---------

**Commit 1:**
[tests] ensure that the notifier is emptied by each test

* Original sha: 0cdef8cd5e
* Authored by spalger <email@spalger.com> on 2016-10-25T00:09:57Z

**Commit 2:**
[testHarness] use generic Error class

* Original sha: 34659fb45f
* Authored by spalger <email@spalger.com> on 2016-10-25T22:11:39Z
This commit is contained in:
Elastic Jasper 2016-10-25 18:15:25 -04:00
parent 47277e994d
commit cfb469b33e
3 changed files with 17 additions and 4 deletions

View file

@ -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();
});

View file

@ -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');

View file

@ -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 () {