tests
This commit is contained in:
parent
8f06e0221f
commit
7de418362e
3 changed files with 30 additions and 2 deletions
|
@ -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")) {
|
||||||
|
|
|
@ -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", () => {
|
||||||
{
|
{
|
28
tests/utils/reminder.test.ts
Normal file
28
tests/utils/reminder.test.ts
Normal 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" });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue