Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Feb 11, 2016
1 parent 5f7b01b commit 4b6f673
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/test/nmea.js

This file was deleted.

43 changes: 43 additions & 0 deletions test/test.js
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');
});
});
});

0 comments on commit 4b6f673

Please sign in to comment.