Skip to content

Commit

Permalink
tests: add test for little endian MXPGN
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 committed Jul 25, 2024
1 parent 6dfb34f commit 2166890
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/mxpgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,45 @@ describe('from mxpgn data converts', function () {

fromPgn.parseString(mxpgn)
})

it(`from little endian 129025 converts`, function (done) {
var mxpgn = '$MXPGN,01F801,2801,43E35D0CC48A30C1'
var expected = {
"pgn":129025,
"src":1,
"dst":255,
"prio":0,
"fields":{
"Latitude": -99.7576511,
"Longitude": 113.8973964,
},
"description":"Position, Rapid Update"
}

var fromPgn = new FromPgn({littleEndianMXPGN:true})

fromPgn.on('error', (pgn, error) => {
console.error(`Error parsing ${pgn.pgn} ${error}`)
console.error(error.stack)
done(error)
})

fromPgn.on('warning', (pgn, warning) => {
done(new Error(`${pgn.pgn} ${warning}`))
})

fromPgn.on('pgn', (pgn) => {
try {
//console.log(JSON.stringify(pgn))
delete pgn.input
delete pgn.timestamp
pgn.should.jsonEqual(expected)
done()
} catch ( e ) {
done(e)
}
})

fromPgn.parseString(mxpgn)
})
})

0 comments on commit 2166890

Please sign in to comment.