anki/ts/deckconfig/steps.test.ts
Damien Elmes 7f738c11a2 deck config prototype work in progress
Still in the early stages, and not hooked up yet.
2021-04-14 22:33:10 +10:00

24 lines
818 B
TypeScript

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { stepsToString, stringToSteps } from "./steps";
test("whole steps", () => {
const steps = [1, 10, 60, 120, 1440];
const string = "1m 10m 1h 2h 1d";
expect(stepsToString(steps)).toBe(string);
expect(stringToSteps(string)).toStrictEqual(steps);
});
test("fractional steps", () => {
const steps = [1 / 60, 5 / 60, 1.5, 400];
const string = "1s 5s 90s 400m";
expect(stepsToString(steps)).toBe(string);
expect(stringToSteps(string)).toStrictEqual(steps);
});
test("parsing", () => {
expect(stringToSteps("")).toStrictEqual([]);
expect(stringToSteps(" ")).toStrictEqual([]);
expect(stringToSteps("1 hello 2")).toStrictEqual([1, 2]);
});