mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[notifier] ensure that notifications are not left around
This commit is contained in:
parent
0757c45dfa
commit
2dbb462bc1
4 changed files with 19 additions and 6 deletions
|
@ -51,9 +51,9 @@ describe('ResponseWriter class', function () {
|
|||
|
||||
it('collects the aggConfigs from each column in aggStack', function () {
|
||||
let aggs = [
|
||||
{ type: 'date_histogram', schema: 'segment', params: { field: '@timestamp' } },
|
||||
{ type: 'date_histogram', schema: 'segment', params: { field: 'time' } },
|
||||
{ type: 'terms', schema: 'segment', params: { field: 'extension' } },
|
||||
{ type: 'avg', schema: 'metric', params: { field: '@timestamp' } }
|
||||
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } }
|
||||
];
|
||||
|
||||
getColumns.returns(aggs.map(function (agg) {
|
||||
|
|
|
@ -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; // clear global notifications
|
||||
});
|
||||
|
||||
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; // clear global notifications
|
||||
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; // reset the global notification array
|
||||
});
|
||||
|
||||
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 TypeError('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