@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
41 lines (40 loc) • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
describe('WahooAPIEventMetaData', () => {
it('serializes stable Wahoo identifiers without a temporary FIT URL', () => {
const metadata = new __1.WahooAPIEventMetaData('workout-1', 'summary-2', 'user-3', '2026-07-18T10:00:00.000Z', new Date('2026-07-18T10:01:00.000Z'), false, true, 6);
expect(metadata.toJSON()).toEqual({
serviceWorkoutID: 'workout-1',
serviceWorkoutSummaryID: 'summary-2',
serviceUserID: 'user-3',
serviceSummaryUpdatedAt: '2026-07-18T10:00:00.000Z',
serviceManual: false,
serviceEdited: true,
serviceFitnessAppID: 6,
serviceName: __1.ServiceNames.WahooAPI,
date: new Date('2026-07-18T10:01:00.000Z').getTime()
});
expect(metadata.toJSON()).not.toHaveProperty('serviceFITFileURI');
});
it('is consumable through the provider-neutral event metadata contract', () => {
const metadata = new __1.WahooAPIEventMetaData('workout-1', 'summary-2', 'user-3', '2026-07-18T10:00:00.000Z', new Date('2026-07-18T10:01:00.000Z'));
expect(metadata.serviceName).toBe(__1.ServiceNames.WahooAPI);
expect(metadata.toJSON()).toMatchObject({
serviceName: __1.ServiceNames.WahooAPI,
date: new Date('2026-07-18T10:01:00.000Z').getTime()
});
});
it('omits absent optional workout flags from a JSON round trip', () => {
const metadata = new __1.WahooAPIEventMetaData('workout-1', 'summary-2', 'user-3', '2026-07-18T10:00:00.000Z', new Date('2026-07-18T10:01:00.000Z'));
const serialized = JSON.parse(JSON.stringify(metadata.toJSON()));
expect(serialized).toEqual({
serviceWorkoutID: 'workout-1',
serviceWorkoutSummaryID: 'summary-2',
serviceUserID: 'user-3',
serviceSummaryUpdatedAt: '2026-07-18T10:00:00.000Z',
serviceName: __1.ServiceNames.WahooAPI,
date: new Date('2026-07-18T10:01:00.000Z').getTime()
});
});
});