UNPKG

@sports-alliance/sports-lib

Version:

A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc

42 lines (41 loc) 2.45 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const xmldom_1 = require("@xmldom/xmldom"); const importer_gpx_1 = require("./importer.gpx"); const data_duration_1 = require("../../../../data/data.duration"); const data_elapsed_time_1 = require("../../../../data/data.elapsed-time"); const data_timer_time_1 = require("../../../../data/data.timer-time"); describe('EventImporterGPX duration policy', () => { it('emits elapsed and active duration stats consistently', () => __awaiter(void 0, void 0, void 0, function* () { var _a, _b, _c, _d; const gpxString = `<?xml version="1.0" encoding="UTF-8"?> <gpx creator="test" version="1.1" xmlns="http://www.topografix.com/GPX/1/1"> <trk> <name>duration-policy</name> <trkseg> <trkpt lat="45.0" lon="9.0"> <time>2026-01-01T10:00:00Z</time> </trkpt> <trkpt lat="45.1" lon="9.1"> <time>2026-01-01T10:01:30Z</time> </trkpt> </trkseg> </trk> </gpx>`; const event = yield importer_gpx_1.EventImporterGPX.getFromString(gpxString, xmldom_1.DOMParser); const activity = event.getFirstActivity(); expect((_a = activity.getStat(data_elapsed_time_1.DataElapsedTime.type)) === null || _a === void 0 ? void 0 : _a.getValue()).toBe(90); expect((_b = activity.getDuration()) === null || _b === void 0 ? void 0 : _b.getValue()).toBe(90); expect((_c = activity.getStat(data_timer_time_1.DataTimerTime.type)) === null || _c === void 0 ? void 0 : _c.getValue()).toBe(90); expect((_d = activity.getStat(data_duration_1.DataDuration.type)) === null || _d === void 0 ? void 0 : _d.getValue()).toBe(90); })); });