@@ -5,7 +5,6 @@ var fs = require('fs');
55// Actual data stream taken from APM.
66global . fixtures = global . fixtures || { } ;
77global . fixtures . serialStream = fs . readFileSync ( "test/capture.mavlink" ) ;
8- //global.fixtures.heartbeatBinaryStream = fs.readFileSync("javascript/test/heartbeat-data-fixture");
98
109describe ( "Generated MAVLink 1.0 protocol handler object" , function ( ) {
1110
@@ -81,14 +80,7 @@ describe("Generated MAVLink 1.0 protocol handler object", function() {
8180
8281 describe ( "buffer decoder (parseBuffer)" , function ( ) {
8382
84- // This test prepopulates a single message as a binary buffer.
85- it ( "decodes a binary stream representation of a single message correctly" , function ( ) {
86- this . m . pushBuffer ( global . fixtures . heartbeatBinaryStream ) ;
87- var messages = this . m . parseBuffer ( ) ;
88-
89- } ) ;
90-
91- // This test includes a "noisy" signal, with non-mavlink data/messages/noise.
83+ // This test includes a "noisy" signal, with non-mavlink data/messages/noise.
9284 it ( "decodes a real serial binary stream into an array of MAVLink messages" , function ( ) {
9385 this . m . pushBuffer ( global . fixtures . serialStream ) ;
9486 var messages = this . m . parseBuffer ( ) ;
@@ -113,11 +105,11 @@ describe("Generated MAVLink 1.0 protocol handler object", function() {
113105 } ) ;
114106
115107 it ( "emits a 'message' event, provisioning callbacks with the message" , function ( done ) {
116- this . m . on ( 'message' , function ( message ) {
117- message . should . be . an . instanceof ( mavlink10 . messages . heartbeat ) ;
108+ this . m . on ( 'message' , function ( message ) {
109+ message . should . be . an . instanceof ( mavlink10 . messages . heartbeat ) ;
118110 done ( ) ;
119- } ) ;
120- this . m . parseChar ( this . heartbeatPayload ) ;
111+ } ) ;
112+ this . m . parseChar ( this . heartbeatPayload ) ;
121113 } ) ;
122114
123115 it ( "emits a 'message' event for bad messages, provisioning callbacks with the message" , function ( done ) {
@@ -129,24 +121,12 @@ describe("Generated MAVLink 1.0 protocol handler object", function() {
129121 this . m . parseChar ( b ) ;
130122 } ) ;
131123
132- it ( "on bad prefix: cuts-off first char in buffer and returns correct bad data" , function ( ) {
133- var b = new Buffer . from ( [ 3 , 0 , 1 , 2 , 3 , 4 , 5 ] ) ; // invalid message
134- var message = this . m . parseChar ( b ) ;
135- message . _msgbuf . length . should . be . eql ( 1 ) ;
136- message . _msgbuf [ 0 ] . should . be . eql ( 3 ) ;
137- this . m . buf . length . should . be . eql ( 6 ) ;
138- // should process next char
139- message = this . m . parseChar ( ) ;
140- message . _msgbuf . length . should . be . eql ( 1 ) ;
141- message . _msgbuf [ 0 ] . should . be . eql ( 0 ) ;
142- this . m . buf . length . should . be . eql ( 5 ) ;
143- } ) ;
144-
145- it ( "on bad message: cuts-off message length and returns correct bad data" , function ( ) {
124+ it ( "on bad message: cuts-off message length and returns correct bad data" , function ( ) {
146125 var message = this . m . parseChar ( this . completeInvalidMessage ) ;
147- message . _msgbuf . length . should . be . eql ( 8 ) ;
148- message . _msgbuf . should . be . eql ( this . completeInvalidMessage ) ;
149- this . m . buf . length . should . be . eql ( 0 ) ;
126+
127+ message . _msgbuf . length . should . be . eql ( 8 ) ;
128+ Buffer . from ( message . _msgbuf ) . should . be . eql ( this . completeInvalidMessage ) ;
129+ this . m . buf . length . should . be . eql ( 0 ) ;
150130 } ) ;
151131
152132 it ( "error counter is raised on error" , function ( ) {
@@ -180,7 +160,7 @@ describe("Generated MAVLink 1.0 protocol handler object", function() {
180160 var b = new Buffer . alloc ( 16 ) ;
181161 b . fill ( "h" ) ;
182162 this . m . pushBuffer ( b ) ;
183- this . m . buf . should . eql ( b ) ; // eql = wiggly equality
163+ Buffer . from ( this . m . buf ) . should . eql ( b ) ; // eql = wiggly equality
184164 } ) ;
185165 } ) ;
186166
0 commit comments