@@ -76,6 +76,7 @@ describe('Homebridge plugin creation', function () {
7676 it ( 'didFinishLaunching callback registers with notification server' , function ( ) {
7777 // 1. Arrange
7878 // Stub created in homebridge.stub.js already since required for every construct.
79+ global . notificationRegistration = sinon . stub ( ) ;
7980
8081 // 2. Act
8182 // Let SUT pass correct didFinishLaunching callback during construction.
@@ -84,9 +85,24 @@ describe('Homebridge plugin creation', function () {
8485 this . homebridgeStub . on . firstCall . lastArg ( ) ;
8586
8687 // 3. Assert
87- expect ( this . homebridgeStub . notificationRegistration . calledOnce ) . equal ( true ) ;
88- expect ( this . homebridgeStub . notificationRegistration . firstCall . args [ 0 ] ) . equal ( 'notification-id-light-a' ) ;
89- expect ( this . homebridgeStub . notificationRegistration . firstCall . lastArg ) . equal ( 'notification-password' ) ;
88+ expect ( global . notificationRegistration . calledOnce ) . equal ( true ) ;
89+ expect ( global . notificationRegistration . firstCall . args [ 0 ] ) . equal ( 'notification-id-light-a' ) ;
90+ expect ( global . notificationRegistration . firstCall . lastArg ) . equal ( 'notification-password' ) ;
91+ } ) ;
92+
93+ it ( 'didFinishLaunching callback does nothing on missing global' , function ( ) {
94+ // 1. Arrange
95+ // Stub created in homebridge.stub.js already since required for every construct.
96+ // Do not create: global.notificationRegistration
97+
98+ // 2. Act
99+ // Let SUT pass correct didFinishLaunching callback during construction.
100+ sut ( this . homebridgeStub ) ;
101+ // Call actual didFinishLaunching callback
102+ this . homebridgeStub . on . firstCall . lastArg ( ) ;
103+
104+ // 3. Assert
105+ expect ( global . notificationRegistration . calledOnce ) . equal ( false ) ;
90106 } ) ;
91107
92108 it ( 'sets switch.status.bodyRegEx by default to /1/' , function ( ) {
0 commit comments