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

63 lines (62 loc) 3.22 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 importer_suunto_json_1 = require("./importer.suunto.json"); 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('EventImporterSuuntoJSON duration policy', () => { it('keeps Duration as active time and exposes elapsed time separately', () => __awaiter(void 0, void 0, void 0, function* () { var _a, _b, _c, _d, _e; const payload = { DeviceLog: { Device: { Name: 'Suunto Test', SerialNumber: '12345', Info: { HW: '1.0', SW: '1.0' } }, Samples: [ { TimeISO8601: '2026-01-01T10:00:00.000Z', Events: [{ Activity: { ActivityType: 3 } }] }, { TimeISO8601: '2026-01-01T10:10:00.000Z', Events: [{ Lap: { Type: 'Stop' } }] } ], Windows: [ { Window: { Type: 'Activity', Duration: 600, PauseDuration: 120 } } ], Header: { DateTime: '2026-01-01T10:00:00.000Z', Duration: 600 } } }; const event = yield importer_suunto_json_1.EventImporterSuuntoJSON.getFromJSONString(JSON.stringify(payload)); const activity = event.getFirstActivity(); expect((_a = activity.getStat(data_elapsed_time_1.DataElapsedTime.type)) === null || _a === void 0 ? void 0 : _a.getValue()).toBe(600); expect((_b = activity.getDuration()) === null || _b === void 0 ? void 0 : _b.getValue()).toBe(480); expect((_c = activity.getStat(data_timer_time_1.DataTimerTime.type)) === null || _c === void 0 ? void 0 : _c.getValue()).toBe(480); expect((_d = activity.getStat(data_duration_1.DataDuration.type)) === null || _d === void 0 ? void 0 : _d.getValue()).toBe(480); expect((_e = activity.getPause()) === null || _e === void 0 ? void 0 : _e.getValue()).toBe(120); })); });