@@ -264,54 +264,77 @@ describe('it should properly unpack binary compressed json messages', function (
264
264
}
265
265
} ) ;
266
266
267
+ it ( 'should unpack the 1-byte version correctly' , function ( ) {
268
+ expect ( outputMsg . version ) . to . equal ( 1 ) ;
269
+ } ) ;
270
+
267
271
it ( 'should unpack the 1-byte message type correctly' , function ( ) {
268
272
expect ( outputMsg . type ) . to . equal ( 'control-message' ) ;
269
273
} ) ;
270
274
275
+ it ( 'should unpack the 1-byte flags correctly' , function ( ) {
276
+ expect ( outputMsg . flags ) . to . equal ( 3 ) ;
277
+ } ) ;
278
+
279
+ it ( 'should unpack the channel name correctly' , function ( ) {
280
+ expect ( outputMsg . channel ) . to . equal ( 'R0' ) ;
281
+ } ) ;
282
+
271
283
it ( 'should unpack the json message body correctly' , function ( ) {
272
284
expect ( outputMsg . event ) . to . equal ( 'JOB_START' ) ;
273
285
expect ( outputMsg . handle ) . to . equal ( 'AAAAAAAAACo' ) ;
274
286
} ) ;
275
287
} ) ;
276
288
277
- // TODO : this test is not working and causes the suite to not complete. fixme later
278
- //describe('it should properly unpack binary compressed data messages', function () {
279
- // var originalMsg = [2, 0, 5, 1, 82, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
280
- // 120, 156, 99, 96, 96, 96, 98, 102, 128, 0, 45, 8, 197, 114, 137, 9,
281
- // 42, 160, 237, 192, 41, 183, 35, 240, 117, 171, 60, 0, 33, 132, 4, 50];
282
- // var arrBuff = new ArrayBuffer(originalMsg.length);
283
- // var typedArr = new Uint8Array(arrBuff);
284
- // originalMsg.forEach(function (val, idx) {
285
- // typedArr[idx] = val;
286
- // });
287
- //
288
- // var outputMsg = wsmh.parseWebSocketMessage({data: arrBuff}, {
289
- // R0: {
290
- // params: {
291
- // }
292
- // }
293
- // });
294
- //
295
- // it('should unpack the 2-byte version correctly', function () {
296
- // expect(outputMsg.version).to.equal(512);
297
- // });
298
- //
299
- // it('should unpack the 1-byte message type correctly', function () {
300
- // expect(outputMsg.type).to.equal('data');
301
- // });
302
- //
303
- // it('should unpack the 1-byte flags correctly', function () {
304
- // expect(outputMsg.flags).to.equal(1);
305
- // });
306
- //
307
- // it('should detect the correct number of datapoints in binary data batch', function () {
308
- // expect(outputMsg.count).to.equal(2);
309
- // });
310
- //
311
- // it('should decode the datapoints correctly from the binary data batch', function () {
312
- // expect(outputMsg.data[0].tsId).to.equal('AAAAAAAAACo');
313
- // expect(outputMsg.data[0].value).to.equal(1234);
314
- // expect(outputMsg.data[1].tsId).to.equal('AAAAAAAAACs');
315
- // expect(outputMsg.data[1].value).to.equal(3.14);
316
- // });
317
- //});
289
+ describe ( 'it should properly unpack binary compressed data messages' , function ( ) {
290
+ var originalMsg = [ 2 , 0 , 5 , 1 , 82 , 48 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
291
+ 120 , 156 , 99 , 96 , 0 , 1 , 150 , 75 , 96 , 138 , 65 , 32 , 3 , 72 , 48 , 49 ,
292
+ 67 , 56 , 12 , 92 , 80 , 90 , 139 , 9 , 202 , 224 , 118 , 224 , 148 , 219 , 17 ,
293
+ 248 , 186 , 85 , 30 , 0 , 74 , 190 , 4 , 148 ] ;
294
+ var arrBuff = new ArrayBuffer ( originalMsg . length ) ;
295
+ var typedArr = new Uint8Array ( arrBuff ) ;
296
+ originalMsg . forEach ( function ( val , idx ) {
297
+ typedArr [ idx ] = val ;
298
+ } ) ;
299
+
300
+ var outputMsg = wsmh . parseWebSocketMessage ( { data : arrBuff } , {
301
+ R0 : {
302
+ params : {
303
+ }
304
+ }
305
+ } ) ;
306
+
307
+ it ( 'should unpack the 2-byte version correctly' , function ( ) {
308
+ expect ( outputMsg . version ) . to . equal ( 512 ) ;
309
+ } ) ;
310
+
311
+ it ( 'should unpack the 1-byte message type correctly' , function ( ) {
312
+ expect ( outputMsg . type ) . to . equal ( 'data' ) ;
313
+ } ) ;
314
+
315
+ it ( 'should unpack the 1-byte flags correctly' , function ( ) {
316
+ expect ( outputMsg . flags ) . to . equal ( 1 ) ;
317
+ } ) ;
318
+
319
+ it ( 'should unpack the correct data batch timestamp' , function ( ) {
320
+ expect ( outputMsg . logicalTimestampMs ) . to . equal ( 1234 ) ;
321
+ } ) ;
322
+
323
+ it ( 'should unpack the correct data batch max delay' , function ( ) {
324
+ expect ( outputMsg . maxDelayMs ) . to . equal ( 4200 ) ;
325
+ } ) ;
326
+
327
+ it ( 'should detect the correct number of datapoints in binary data batch' , function ( ) {
328
+ expect ( outputMsg . data . length ) . to . equal ( 2 ) ;
329
+ } ) ;
330
+
331
+ it ( 'should decode the first datapoint correctly from the binary data batch' , function ( ) {
332
+ expect ( outputMsg . data [ 0 ] . tsId ) . to . equal ( 'AAAAAAAAAAo' ) ;
333
+ expect ( outputMsg . data [ 0 ] . value ) . to . equal ( 42 ) ;
334
+ } ) ;
335
+
336
+ it ( 'should decode the second datapoint correctly from the binary data batch' , function ( ) {
337
+ expect ( outputMsg . data [ 1 ] . tsId ) . to . equal ( 'AAAAAAAAAAs' ) ;
338
+ expect ( outputMsg . data [ 1 ] . value ) . to . equal ( 3.14 ) ;
339
+ } ) ;
340
+ } ) ;
0 commit comments