This commit is contained in:
Mylloon 2024-09-27 12:55:06 +02:00
parent 8f06e0221f
commit 7de418362e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 30 additions and 2 deletions

View file

@ -45,7 +45,7 @@ export type dbReminder = {
* @param time raw text from user * @param time raw text from user
* @returns An object with the time and the option * @returns An object with the time and the option
*/ */
const splitTime = (time: string) => { export const splitTime = (time: string) => {
if (time?.endsWith("@")) { if (time?.endsWith("@")) {
return { time: time.slice(0, -1), option: OptionReminder.Mention }; return { time: time.slice(0, -1), option: OptionReminder.Mention };
} else if (time?.toLowerCase().endsWith("p")) { } else if (time?.toLowerCase().endsWith("p")) {

View file

@ -4,7 +4,7 @@ import {
isImage, isImage,
removeExtension, removeExtension,
splitFilenameExtensions, splitFilenameExtensions,
} from "../src/utils/misc"; } from "../../src/utils/misc";
describe("Filename splitter", () => { describe("Filename splitter", () => {
{ {

View file

@ -0,0 +1,28 @@
import { OptionReminder, splitTime } from "../../src/utils/reminder";
describe("Time splitter", () => {
{
const name = "";
test(name, () => {
expect(splitTime(name)).toStrictEqual({ option: OptionReminder.Nothing, time: "" });
});
}
/* {
const name = "2m@p";
test(name, () => {
expect(splitTime(name)).toStrictEqual({ option: OptionReminder.Mention, time: "2m" });
});
} */
{
const name = "41@";
test(name, () => {
expect(splitTime(name)).toStrictEqual({ option: OptionReminder.Mention, time: "41" });
});
}
{
const name = "0P";
test(name, () => {
expect(splitTime(name)).toStrictEqual({ option: OptionReminder.DirectMessage, time: "0" });
});
}
});