33
44describe ( 'integration of module::vertxEventBus' , function ( ) {
55
6- beforeEach ( module ( 'knalli.angular-vertxbus' ) ) ;
6+ beforeEach ( angular . mock . module ( 'knalli.angular-vertxbus' ) ) ;
77
8- beforeEach ( module ( 'knalli.angular-vertxbus' , function ( $provide ) {
8+ beforeEach ( angular . mock . module ( 'knalli.angular-vertxbus' , function ( $provide ) {
99 $provide . value ( '$log' , window . console ) ;
1010 } ) ) ;
1111
12- it ( 'should have vertxEventBus' , function ( ) {
13- inject ( function ( vertxEventBus ) {
14- expect ( vertxEventBus ) . not . to . be ( undefined ) ;
15- } ) ;
16- } ) ;
12+ it ( 'should have vertxEventBus' , angular . mock . inject ( function ( vertxEventBus ) {
13+ expect ( vertxEventBus ) . not . to . be ( undefined ) ;
14+ } ) ) ;
1715
1816 describe ( 'vertxEventBus (w/ reconnect)' , function ( ) {
1917
2018 var vertxEventBus , $timeout , $rootScope , $log ;
2119
22- beforeEach ( module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
20+ beforeEach ( angular . mock . module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
2321 // Override (improve test running time)
2422 vertxEventBusProvider . useDebug ( true ) . useSockJsReconnectInterval ( 2000 ) ;
2523 } ) ) ;
2624
27- beforeEach ( inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
25+ beforeEach ( angular . mock . inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
2826 vertxEventBus = _vertxEventBus_ ;
2927 $timeout = _$timeout_ ;
3028 $rootScope = _$rootScope_ ;
@@ -224,12 +222,12 @@ describe('integration of module::vertxEventBus', function () {
224222
225223 var vertxEventBus , $timeout , $rootScope , $log ;
226224
227- beforeEach ( module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
225+ beforeEach ( angular . mock . module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
228226 // Override (improve test running time)
229227 vertxEventBusProvider . useDebug ( true ) . useSockJsReconnectInterval ( 2000 ) . useReconnect ( false ) ;
230228 } ) ) ;
231229
232- beforeEach ( inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
230+ beforeEach ( angular . mock . inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
233231 vertxEventBus = _vertxEventBus_ ;
234232 $timeout = _$timeout_ ;
235233 $rootScope = _$rootScope_ ;
@@ -269,7 +267,7 @@ describe('integration of module::vertxEventBus', function () {
269267
270268 var vertxEventBus , $timeout , $rootScope , $log ;
271269
272- beforeEach ( module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
270+ beforeEach ( angular . mock . module ( 'knalli.angular-vertxbus' , function ( vertxEventBusProvider ) {
273271 // Override (improve test running time)
274272 vertxEventBusProvider
275273 . useDebug ( true )
@@ -278,7 +276,7 @@ describe('integration of module::vertxEventBus', function () {
278276 . disableAutoConnect ( ) ;
279277 } ) ) ;
280278
281- beforeEach ( inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
279+ beforeEach ( angular . mock . inject ( function ( _vertxEventBus_ , _$timeout_ , _$rootScope_ , _$log_ ) {
282280 vertxEventBus = _vertxEventBus_ ;
283281 $timeout = _$timeout_ ;
284282 $rootScope = _$rootScope_ ;
@@ -336,12 +334,19 @@ describe('integration of module::vertxEventBus', function () {
336334 expect ( onopenCount ) . to . be ( 0 ) ; // should be not called!
337335 $log . debug ( 'apply connection config..' ) ;
338336 vertxEventBus . configureConnection ( 'http://localhost:1234' , '/eventbus1' ) ;
339- vertxEventBus . connect ( ) ;
337+ var connectPromise = vertxEventBus . connect ( ) ;
338+ expect ( connectPromise ) . not . to . be ( undefined ) ;
339+ var connectPromiseResult = false ;
340+ connectPromise . then ( ( ) => {
341+ connectPromiseResult = true
342+ } ) ;
340343 setTimeout ( function ( ) {
344+ $rootScope . $digest ( ) ; // for $q
341345 $log . debug ( 'check..' ) ;
342346 expect ( SockJS . currentMockInstance . url ) . to . be ( 'http://localhost:1234/eventbus1' ) ;
343347 expect ( onopenCount ) . to . be ( 1 ) ;
344348 expect ( oncloseCount ) . to . be ( 0 ) ;
349+ expect ( connectPromiseResult ) . to . be ( true ) ;
345350 done ( ) ;
346351 } , 1200 ) ;
347352 } , 200 ) ;
0 commit comments