node-gps
Version:
A GPS NMEA parser library
54 lines (43 loc) • 1.17 kB
JavaScript
var expect = require('chai').expect;
var GPS = require('../gps.js');
var pgps = new GPS;
var res = [{
'lat': 48.539856666666665,
'lon': 9.059166666666666,
'speed': 4.22256,
'status': 'active',
'time': new Date('2016-01-26T23:49:19.000Z'),
'track': 2.93,
'raw': '$GPRMC,234919.000,A,4832.3914,N,00903.5500,E,2.28,2.93,260116,,*0D',
'type': 'RMC',
'faa': null,
'valid': true,
'variation': null
}, {
'speed': 4.22256,
'track': 2.93,
'raw': '$GPVTG,2.93,T,,M,2.28,N,4.2,K*66',
'type': 'VTG',
'faa': null,
'valid': true
}
];
describe('partial updates', function() {
it('should work async with partial updates', function(done) {
var K = 0;
pgps.on('data', function(data) {
try {
expect(data).to.deep.equal(res[K++]);
} catch (e) {
done(e);
}
if (K === res.length) {
done();
}
});
pgps.updatePartial("6,,*0D\r\n$GPRMC,234919.000");
pgps.updatePartial(",A,4832.3914,N,00903.5500");
pgps.updatePartial(",E,2.28,2.93,260116,,*0D\r\n$GPVTG,2.");
pgps.updatePartial("93,T,,M,2.28,N,4.2,K*66\r\nfoo");
});
});