mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Backport PR #8822
--------- **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:
parent
47277e994d
commit
cfb469b33e
3 changed files with 17 additions and 4 deletions
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue