@@ -76,6 +76,7 @@ describe('Homebridge plugin creation', function () {
76
76
it ( 'didFinishLaunching callback registers with notification server' , function ( ) {
77
77
// 1. Arrange
78
78
// Stub created in homebridge.stub.js already since required for every construct.
79
+ global . notificationRegistration = sinon . stub ( ) ;
79
80
80
81
// 2. Act
81
82
// Let SUT pass correct didFinishLaunching callback during construction.
@@ -84,9 +85,24 @@ describe('Homebridge plugin creation', function () {
84
85
this . homebridgeStub . on . firstCall . lastArg ( ) ;
85
86
86
87
// 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 ) ;
90
106
} ) ;
91
107
92
108
it ( 'sets switch.status.bodyRegEx by default to /1/' , function ( ) {
0 commit comments