From 2166890e1602d80acf057aec9b12f0a69c536c63 Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Thu, 25 Jul 2024 09:50:44 -0400 Subject: [PATCH] tests: add test for little endian MXPGN --- test/mxpgn.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/mxpgn.js b/test/mxpgn.js index 6f88339..4a70a52 100644 --- a/test/mxpgn.js +++ b/test/mxpgn.js @@ -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) + }) })