/
vasya2
/
var
Обзор
Документация
Войти
/
vasya2
/
var
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
api/src/utils/progress.test.ts
39 строк
1 KB
Oliver Eyton-Williams
feat(api): add /user/get-session-user (#50557)
11 июл 2023, 19:28
Не верифицирован
11 июл 2023, 19:28
6e787d3
Код
Авторство
О чём код?
import { getCalendar, getPoints } from './progress'; describe('utils/progress', () => { describe('getCalendar', () => { it('should return an empty object if no timestamps are passed', () => { expect(getCalendar([])).toEqual({}); expect(getCalendar(null)).toEqual({}); }); it('should take timestamps and return a calendar object', () => { const timestamps = [-1111001, 0, 1111000, 1111500, 1113000, 9999999]; expect(getCalendar(timestamps)).toEqual({ '-1112': 1, 0: 1, 1111: 1, 1113: 1, 9999: 1 }); }); it('should handle null, { timestamp: number } and float entries', () => { const timestamps = [null, { timestamp: 1113000 }, 1111000.5]; expect(getCalendar(timestamps)).toEqual({ 1111: 1, 1113: 1 }); }); }); describe('getPoints', () => { it('should return 1 if there are no progressTimestamps', () => { expect(getPoints(null)).toEqual(1); }); it('should return then number of progressTimestamps if there are any', () => { expect(getPoints([0, 1, 2])).toEqual(3); }); }); });