@@ -54,6 +54,55 @@ describe('Nmea', () => {
5454 } ) ;
5555 } ) ;
5656
57+ describe ( 'GPRMC alternative' , ( ) => {
58+ const data = '$GPRMC,192053.00,A,4212.63658,N,00844.30075,W,0.648,295.88,010616,,,A*76' ;
59+ const parser = nmea . parse ( data ) ;
60+
61+ it ( 'should return the same value passed in the constructor' , ( ) => {
62+ expect ( data ) . to . eql ( parser . raw ) ;
63+ } ) ;
64+
65+ it ( 'should return true if checksum is valid' , ( ) => {
66+ expect ( nmea . isValid ( parser . raw ) ) . to . be . true ;
67+ } ) ;
68+
69+ it ( 'should return true if datetime values is valid' , ( ) => {
70+ const datetime = moment . utc ( parser . datetime ) ;
71+ const date = datetime . format ( 'DDMMYY' ) ;
72+ expect ( date ) . to . eql ( '010616' ) ;
73+ const time = datetime . format ( 'HHmmss' ) ;
74+ expect ( time ) . to . eql ( '192053' ) ;
75+ } ) ;
76+
77+ it ( 'should return true if position values is valid' , ( ) => {
78+ expect ( parser . loc . geojson . type ) . to . eql ( 'Point' ) ;
79+ expect ( parser . loc . geojson . coordinates . length ) . to . eql ( 2 ) ;
80+ expect ( parser . loc . dmm . latitude ) . to . eql ( '4212.63658,N' ) ;
81+ expect ( parser . loc . dmm . longitude ) . to . eql ( '00844.30075,W' ) ;
82+ } ) ;
83+
84+ it ( 'should return true if gps value is valid' , ( ) => {
85+ expect ( parser . gps ) . to . be . true ;
86+ } ) ;
87+
88+ it ( 'should return true if speed value is valid' , ( ) => {
89+ expect ( parser . speed . knots ) . to . eql ( 0.648 ) ;
90+ expect ( parser . speed . kmh ) . to . eql ( 1.200096 ) ;
91+ } ) ;
92+
93+ it ( 'should return true if track value is valid' , ( ) => {
94+ expect ( parser . track ) . to . eql ( '295.88' ) ;
95+ } ) ;
96+
97+ it ( 'should return true if magnetic variation value is valid' , ( ) => {
98+ expect ( parser . magneticVariation ) . to . be . null ;
99+ } ) ;
100+
101+ it ( 'should return true if mode value is valid' , ( ) => {
102+ expect ( parser . mode ) . to . eql ( 'Autonomous' ) ;
103+ } ) ;
104+ } ) ;
105+
57106 describe ( 'GPGGA' , ( ) => {
58107 const data = '$GPGGA,172814.0,3723.46587704,N,12202.26957864,W,2,6,1.2,18.893,M,-25.669,M,2.0,0031*4F' ;
59108 const parser = nmea . parse ( data ) ;
0 commit comments