@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
46 lines (45 loc) • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
describe('user service contracts', () => {
it('exposes Wahoo in the complete service-name registry', () => {
expect(Object.values(__1.ServiceNames)).toEqual([
__1.ServiceNames.SuuntoApp,
__1.ServiceNames.GarminAPI,
__1.ServiceNames.COROSAPI,
__1.ServiceNames.WahooAPI
]);
expect(__1.ServiceNames.WahooAPI).toBe('Wahoo API');
});
it('keeps the stable Wahoo user ID on the OAuth token contract', () => {
const wahooToken = {
id: 'token-1',
serviceName: __1.ServiceNames.WahooAPI,
accessToken: 'access-token',
refreshToken: 'refresh-token',
tokenType: 'bearer',
expiresAt: 1752835600000,
scope: 'user_read workouts_read offline_data',
dateRefreshed: 1752828400000,
dateCreated: 1752828000000,
wahooUserID: 'wahoo-user-42'
};
const providerNeutralToken = wahooToken;
expect(providerNeutralToken.serviceName).toBe(__1.ServiceNames.WahooAPI);
expect(wahooToken.wahooUserID).toBe('wahoo-user-42');
expect(wahooToken.scope.split(' ')).toEqual(['user_read', 'workouts_read', 'offline_data']);
});
it('supports Wahoo history state in provider-keyed user service metadata', () => {
const services = {
[__1.ServiceNames.WahooAPI]: {
didLastHistoryImport: 1752828400000,
processedActivitiesFromLastHistoryImportCount: 27
}
};
expect(services[__1.ServiceNames.WahooAPI]).toEqual({
didLastHistoryImport: 1752828400000,
processedActivitiesFromLastHistoryImportCount: 27
});
expect(services[__1.ServiceNames.WahooAPI]).not.toHaveProperty('uploadedRoutesCount');
});
});