<commit_before>'use strict';

const nmea = require('../src');
const expect = require('chai').expect;
const moment = require('moment');

describe('Nmea', () => {
  describe('GPRMC', () => {
    const data = '$GPRMC,194329.000,A,3321.6735,S,07030.7640,W,0.00,0.00,090216,,,A*6C';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.isValid(parser.raw)).to.be.true;
    });

    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');
    });

    it('should return true if position values is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('3321.6735,S');
      expect(parser.loc.dmm.longitude).to.eql('07030.7640,W');
    });

    it('should return true if gps value is valid', () => {
      expect(parser.gps).to.be.true;
    });

    it('should return true if speed value is valid', () => {
      expect(parser.speed.knots).to.eql(0);
      expect(parser.speed.kmh).to.eql(0);
    });

    it('should return true if track value is valid', () => {
      expect(parser.track).to.eql('0.00');
    });

    it('should return true if magnetic variation value is valid', () => {
      expect(parser.magneticVariation).to.be.null;
    });

    it('should return true if mode value is valid', () => {
      expect(parser.mode).to.eql('Autonomous');
    });
  });

  describe('GPRMC alternative', () => {
    const data = '$GPRMC,192053.00,A,4212.63658,N,00844.30075,W,0.648,295.88,010616,,,A*76';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.isValid(parser.raw)).to.be.true;
    });

    it('should return true if datetime values is valid', () => {
      const datetime = moment.utc(parser.datetime);
      const date = datetime.format('DDMMYY');
      expect(date).to.eql('010616');
      const time = datetime.format('HHmmss');
      expect(time).to.eql('192053');
    });

    it('should return true if position values is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('4212.63658,N');
      expect(parser.loc.dmm.longitude).to.eql('00844.30075,W');
    });

    it('should return true if gps value is valid', () => {
      expect(parser.gps).to.be.true;
    });

    it('should return true if speed value is valid', () => {
      expect(parser.speed.knots).to.eql(0.648);
      expect(parser.speed.kmh).to.eql(1.200096);
    });

    it('should return true if track value is valid', () => {
      expect(parser.track).to.eql('295.88');
    });

    it('should return true if magnetic variation value is valid', () => {
      expect(parser.magneticVariation).to.be.null;
    });

    it('should return true if mode value is valid', () => {
      expect(parser.mode).to.eql('Autonomous');
    });
  });

  describe('GPGGA', () => {
    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';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.verifyChecksum(parser.raw)).to.be.true;
    });

    it('should return true if datetime value is valid', () => {
      const datetime = moment.utc(parser.datetime);
      const time = datetime.format('HHmmss');
      expect(time).to.eql('172814');
    });

    it('should return true if position value is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('3723.46587704,N');
      expect(parser.loc.dmm.longitude).to.eql('12202.26957864,W');
    });

    it('should return true if gps quality value is valid', () => {
      expect(parser.gpsQuality).to.eql('DGPS fix');
    });

    it('should return true if satellites value is valid', () => {
      expect(parser.satellites).to.eql(6);
    });

    it('should return true if hdop value is valid', () => {
      expect(parser.hdop).to.eql(1.2);
    });

    it('should return true if altitude values is valid', () => {<commit_msg>chore(src): Remove moment<commit_after>'use strict';

const nmea = require('../src');
const expect = require('chai').expect;

describe('Nmea', () => {
  describe('GPRMC', () => {
    const data = '$GPRMC,194329.000,A,3321.6735,S,07030.7640,W,0.00,0.00,090216,,,A*6C';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.isValid(parser.raw)).to.be.true;
    });

    it('should return true if position values is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('3321.6735,S');
      expect(parser.loc.dmm.longitude).to.eql('07030.7640,W');
    });

    it('should return true if gps value is valid', () => {
      expect(parser.gps).to.be.true;
    });

    it('should return true if speed value is valid', () => {
      expect(parser.speed.knots).to.eql(0);
      expect(parser.speed.kmh).to.eql(0);
    });

    it('should return true if track value is valid', () => {
      expect(parser.track).to.eql('0.00');
    });

    it('should return true if magnetic variation value is valid', () => {
      expect(parser.magneticVariation).to.be.null;
    });

    it('should return true if mode value is valid', () => {
      expect(parser.mode).to.eql('Autonomous');
    });
  });

  describe('GPRMC alternative', () => {
    const data = '$GPRMC,192053.00,A,4212.63658,N,00844.30075,W,0.648,295.88,010616,,,A*76';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.isValid(parser.raw)).to.be.true;
    });

    it('should return true if position values is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('4212.63658,N');
      expect(parser.loc.dmm.longitude).to.eql('00844.30075,W');
    });

    it('should return true if gps value is valid', () => {
      expect(parser.gps).to.be.true;
    });

    it('should return true if speed value is valid', () => {
      expect(parser.speed.knots).to.eql(0.648);
      expect(parser.speed.kmh).to.eql(1.200096);
    });

    it('should return true if track value is valid', () => {
      expect(parser.track).to.eql('295.88');
    });

    it('should return true if magnetic variation value is valid', () => {
      expect(parser.magneticVariation).to.be.null;
    });

    it('should return true if mode value is valid', () => {
      expect(parser.mode).to.eql('Autonomous');
    });
  });

  describe('GPGGA', () => {
    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';
    const parser = nmea.parse(data);

    it('should return the same value passed in the constructor', () => {
      expect(data).to.eql(parser.raw);
    });

    it('should return true if checksum is valid', () => {
      expect(nmea.verifyChecksum(parser.raw)).to.be.true;
    });

    it('should return true if position value is valid', () => {
      expect(parser.loc.geojson.type).to.eql('Point');
      expect(parser.loc.geojson.coordinates.length).to.eql(2);
      expect(parser.loc.dmm.latitude).to.eql('3723.46587704,N');
      expect(parser.loc.dmm.longitude).to.eql('12202.26957864,W');
    });

    it('should return true if gps quality value is valid', () => {
      expect(parser.gpsQuality).to.eql('DGPS fix');
    });

    it('should return true if satellites value is valid', () => {
      expect(parser.satellites).to.eql(6);
    });

    it('should return true if hdop value is valid', () => {
      expect(parser.hdop).to.eql(1.2);
    });

    it('should return true if altitude values is valid', () => {
{'fraction_non_alphanumeric': 0.18947249774571687, 'fraction_numerical': 0.05421550946798918, 'mean_word_length': 3.0964912280701755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1591296', 'n_tokens_mistral': 3369, 'n_tokens_neox': 3053, 'n_words': 562}