-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
import nmea from '../lib'; | ||
import {expect} from 'chai'; | ||
import moment from 'moment'; | ||
|
||
describe('Nmea', () => { | ||
const data = '$GPRMC,194329.000,A,3321.6735,S,07030.7640,W,0.00,0.00,090216,,,A*6C'; | ||
const parser = nmea.parse(data); | ||
|
||
describe('#this.raw', () => { | ||
it('should return the same value passed in the constructor', () => { | ||
expect(data).to.eql(parser.raw); | ||
}); | ||
}); | ||
|
||
describe('#this.isValid()', () => { | ||
it('should return true if checksum is valid', () => { | ||
expect(nmea.isValid(parser.raw)).to.be.true; | ||
}); | ||
}); | ||
|
||
describe('#this.datetime', () => { | ||
it('should return true if datetime values is valid', () => { | ||
const datetime = moment.utc(parser.datetime); | ||
const date = datetime.format('DDMMYY'); | ||
expect(date).to.eql('090216'); | ||
const time = datetime.format('HHmmss.SSS'); | ||
expect(time).to.eql('194329.000'); | ||
}); | ||
}); | ||
|
||
describe('#this.loc', () => { | ||
it('should return true if position values is valid', () => { | ||
expect(parser.loc.type).to.eql('Point'); | ||
expect(parser.loc.coordinates.length).to.eql(2); | ||
const lng = nmea.lngToDmm(parser.loc.coordinates[0]); | ||
const lat = nmea.latToDmm(parser.loc.coordinates[1]); | ||
expect(lat).to.eql('3321.6735,S'); | ||
expect(lng).to.eql('07030.7640,W'); | ||
}); | ||
}); | ||
}); |