@@ -51,8 +51,12 @@ void describe('processNrplusMessagesAndUpdateThingShadow', () => {
5151 type : 'device.messages' ,
5252 timestamp : '' ,
5353 } )
54- assert . equal ( ensureThing . mock . calls . length , 1 ) // ensureThing is called
55- assert . equal ( updateShadow . mock . calls . length , 0 ) // updateShadow is not called because message is undefined
54+ assert . equal ( ensureThing . mock . calls . length , 1 , 'ensureThing is called' )
55+ assert . equal (
56+ updateShadow . mock . calls . length ,
57+ 0 ,
58+ 'updateShadow is not called because message is undefined' ,
59+ )
5660 } )
5761 void it ( 'should process a location message and update shadow when thing exists and format is correct' , async ( ) => {
5862 const thingName = 'team1'
@@ -83,27 +87,31 @@ void describe('processNrplusMessagesAndUpdateThingShadow', () => {
8387 type : 'device.messages' ,
8488 timestamp : '' ,
8589 } )
86- assert . equal ( ensureThing . mock . calls . length , 1 ) // ensureThing is called
87- assert . equal ( updateShadow . mock . calls . length , 1 ) // updateShadow is called
90+ assert . equal ( ensureThing . mock . calls . length , 1 , ' ensureThing is called' )
91+ assert . equal ( updateShadow . mock . calls . length , 1 , ' updateShadow is called' )
8892
8993 const firstCallUpdate = updateShadow . mock . calls [ 0 ]
9094 const secondArgumentUpdate = Array . isArray ( firstCallUpdate )
9195 ? firstCallUpdate [ 1 ]
9296 : ( firstCallUpdate as any ) . arguments ?. [ 1 ]
93- assert . deepEqual ( secondArgumentUpdate , [
94- {
95- ObjectID : 14201 ,
96- ObjectVersion : '1.0' ,
97- ObjectInstanceID : 1 ,
98- Resources : {
99- '0' : 63.4317043 ,
100- '1' : 10.4711207 ,
101- '3' : 17.245 ,
102- '6' : 'WIFI' ,
103- '99' : Date . parse ( receivedAt ) / 1000 ,
97+ assert . deepEqual (
98+ secondArgumentUpdate ,
99+ [
100+ {
101+ ObjectID : 14201 ,
102+ ObjectVersion : '1.0' ,
103+ ObjectInstanceID : 1 ,
104+ Resources : {
105+ '0' : 63.4317043 ,
106+ '1' : 10.4711207 ,
107+ '3' : 17.245 ,
108+ '6' : 'WIFI' ,
109+ '99' : Date . parse ( receivedAt ) / 1000 ,
110+ } ,
104111 } ,
105- } ,
106- ] ) // updateShadow is called with correct message
112+ ] ,
113+ 'updateShadow is called with correct message' ,
114+ )
107115 } )
108116 void it ( 'should not update shadow if message is unhandled' , async ( ) => {
109117 const thingName = 'team1'
@@ -131,41 +139,53 @@ void describe('processNrplusMessagesAndUpdateThingShadow', () => {
131139 type : 'device.messages' ,
132140 timestamp : '' ,
133141 } )
134- assert . equal ( ensureThing . mock . calls . length , 1 ) // ensureThing is called
135- assert . equal ( updateShadow . mock . calls . length , 1 ) // updateShadow is called
142+ assert . equal ( ensureThing . mock . calls . length , 1 , ' ensureThing is called' )
143+ assert . equal ( updateShadow . mock . calls . length , 1 , ' updateShadow is called' )
136144
137145 const firstCall = ensureThing . mock . calls [ 0 ]
138146 const firstArgument = Array . isArray ( firstCall )
139147 ? firstCall [ 0 ]
140148 : ( firstCall as any ) . arguments ?. [ 0 ]
141- assert . equal ( firstArgument , thingName + '-' + deviceId ) // ensureThing is called with correct thingName
149+ assert . equal (
150+ firstArgument ,
151+ thingName + '-' + deviceId ,
152+ 'ensureThing is called with correct thingName' ,
153+ )
142154
143155 const firstCallUpdate = updateShadow . mock . calls [ 0 ]
144156 const firstArgumentUpdate = Array . isArray ( firstCallUpdate )
145157 ? firstCallUpdate [ 0 ]
146158 : ( firstCallUpdate as any ) . arguments ?. [ 0 ]
147- assert . equal ( firstArgumentUpdate , thingName + '-' + deviceId ) // updateShadow is called with correct thingName
159+ assert . equal (
160+ firstArgumentUpdate ,
161+ thingName + '-' + deviceId ,
162+ 'updateShadow is called with correct thingName' ,
163+ )
148164
149165 const secondArgumentUpdate = Array . isArray ( firstCallUpdate )
150166 ? firstCallUpdate [ 1 ]
151167 : ( firstCallUpdate as any ) . arguments ?. [ 1 ]
152- assert . deepEqual ( secondArgumentUpdate , [
153- {
154- ObjectID : 14503 ,
155- ObjectVersion : '1.0' ,
156- Resources : {
157- '0' : 1592461780 ,
158- '1' : 703710 ,
159- '2' : 'FT' ,
160- '99' : 1760514064 ,
168+ assert . deepEqual (
169+ secondArgumentUpdate ,
170+ [
171+ {
172+ ObjectID : 14503 ,
173+ ObjectVersion : '1.0' ,
174+ Resources : {
175+ '0' : 1592461780 ,
176+ '1' : 703710 ,
177+ '2' : 'FT' ,
178+ '99' : 1760514064 ,
179+ } ,
180+ } ,
181+ {
182+ ObjectID : 14502 ,
183+ ObjectVersion : '1.0' ,
184+ Resources : { '0' : 696113427 , '1' : 0 , '99' : 1760524760 } ,
161185 } ,
162- } ,
163- {
164- ObjectID : 14502 ,
165- ObjectVersion : '1.0' ,
166- Resources : { '0' : 696113427 , '1' : 0 , '99' : 1760524760 } ,
167- } ,
168- ] ) // updateShadow is called with correct message
186+ ] ,
187+ 'updateShadow is called with correct message' ,
188+ )
169189 } )
170190 void it ( 'should not update shadow if message is unhandled' , async ( ) => {
171191 const thingName = 'team1'
@@ -188,7 +208,11 @@ void describe('processNrplusMessagesAndUpdateThingShadow', () => {
188208 type : 'device.messages' ,
189209 timestamp : '' ,
190210 } )
191- assert . equal ( ensureThing . mock . calls . length , 1 ) // ensureThing is called
192- assert . equal ( updateShadow . mock . calls . length , 0 ) // updateShadow is not called
211+ assert . equal ( ensureThing . mock . calls . length , 1 , 'ensureThing is called' )
212+ assert . equal (
213+ updateShadow . mock . calls . length ,
214+ 0 ,
215+ 'updateShadow is not called' ,
216+ )
193217 } )
194218} )
0 commit comments