File tree Expand file tree Collapse file tree
route_based_notifier/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,10 +33,13 @@ describe('Notifier', function () {
3333
3434 beforeEach ( function ( ) {
3535 params = { location : 'foo' } ;
36- while ( Notifier . prototype . _notifs . pop ( ) ) ; // clear global notifications
3736 notifier = new Notifier ( params ) ;
3837 } ) ;
3938
39+ afterEach ( function ( ) {
40+ Notifier . prototype . _notifs . length = 0 ;
41+ } ) ;
42+
4043 describe ( '#constructor()' , function ( ) {
4144 it ( 'sets #from from given location' , function ( ) {
4245 expect ( notifier . from ) . to . equal ( params . location ) ;
@@ -465,13 +468,12 @@ describe('Directive Notification', function () {
465468 scope ;
466469 } ) ;
467470
468- while ( Notifier . prototype . _notifs . pop ( ) ) ; // clear global notifications
469-
470471 notifier = new Notifier ( { location : 'directiveFoo' } ) ;
471472 directiveNotification = notifier . directive ( directiveParam , customParams ) ;
472473 } ) ;
473474
474475 afterEach ( ( ) => {
476+ Notifier . prototype . _notifs . length = 0 ;
475477 directiveNotification . clear ( ) ;
476478 scope . $destroy ( ) ;
477479 } ) ;
Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ describe('ui/route_based_notifier', function () {
1010
1111 beforeEach ( ngMock . module ( 'kibana' ) ) ;
1212 beforeEach ( ngMock . inject ( ( $injector ) => {
13- remove ( Notifier . prototype . _notifs ) ; // hack to reset the global notification array
1413 const Private = $injector . get ( 'Private' ) ;
1514 routeBasedNotifier = Private ( routeBasedNotifierProvider ) ;
1615 $rootScope = $injector . get ( '$rootScope' ) ;
1716 } ) ) ;
1817
18+ afterEach ( ( ) => {
19+ Notifier . prototype . _notifs . length = 0 ;
20+ } ) ;
21+
1922 describe ( '#warning()' , ( ) => {
2023 it ( 'adds a warning notification' , ( ) => {
2124 routeBasedNotifier . warning ( 'wat' ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import chrome from 'ui/chrome';
66import Nonsense from 'Nonsense' ;
77import sinon from 'sinon' ;
88import _ from 'lodash' ;
9+ import Notifier from 'ui/notify/notifier' ;
910
1011import StackTraceMapper from 'ui/stack_trace_mapper' ;
1112import { parse } from 'url' ;
@@ -55,6 +56,13 @@ before(function () {
5556 sinon . useFakeXMLHttpRequest ( ) ;
5657} ) ;
5758
59+ beforeEach ( function ( ) {
60+ if ( Notifier . prototype . _notifs . length ) {
61+ Notifier . prototype . _notifs . length = 0 ;
62+ throw new Error ( 'notifications were left in the notifier' ) ;
63+ }
64+ } ) ;
65+
5866
5967/*** Kick off mocha, called at the end of test entry files ***/
6068exports . bootstrap = function ( ) {
You can’t perform that action at this time.
0 commit comments