Compare commits

..

No commits in common. "af8ba14b83a7b3fcf75195a33ce7bd9a9c58b208" and "e9aff483b1bcdae36b02b9147cbfc9c1cf60d21f" have entirely different histories.

7 changed files with 5 additions and 67 deletions

3
.gitignore vendored
View file

@ -15,6 +15,3 @@ dist/
# Debug file # Debug file
src/events/player/debug.ts src/events/player/debug.ts
# Jest
coverage/

View file

@ -291,7 +291,8 @@ Pour commencer, vous pouvez jeter un œil aux
Il est souhaité d'écrire des tests quand cela est possible. Il est souhaité d'écrire des tests quand cela est possible.
```ts ```ts
import { fnReturnsTrue } from "../src/utils/file"; // eslint-disable-next-line @typescript-eslint/no-require-imports
const { fnReturnsTrue } = require("../src/utils/misc");
describe("test name", () => { describe("test name", () => {
{ {

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
*/ */
export const splitTime = (time: string) => { 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

@ -9,9 +9,8 @@ import moment from "moment-timezone";
*/ */
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => { export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => {
const localeInfo = new Intl.Locale(tz); const localeInfo = new Intl.Locale(tz);
const intlTimezone = moment.tz.zonesForCountry(localeInfo.region ?? localeInfo.baseName);
const formattedDate = new Intl.DateTimeFormat(tz, { const formattedDate = new Intl.DateTimeFormat(tz, {
timeZone: intlTimezone ? intlTimezone[0] : "Etc/GMT", timeZone: moment.tz.zonesForCountry(localeInfo.region ?? localeInfo.baseName)[0],
dateStyle: "short", dateStyle: "short",
timeStyle: "medium", timeStyle: "medium",
}) })

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

@ -1,28 +0,0 @@
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" });
});
}
});

View file

@ -1,31 +0,0 @@
import { showDate } from "../../src/utils/time";
describe("Date with correct timezone", () => {
const map: Map<string, unknown> = new Map([["u_time_at", "@"]]);
const date = new Date(1727434767686);
{
const name = "fr";
test(name, () => {
expect(showDate(name, map, date)).toBe("27/09/2024 @ 12:59:27");
});
}
{
const name = "en-US";
test(name, () => {
expect(showDate(name, map, date)).toBe("9/27/24, @ 1:59:27");
});
}
{
const name = "unknown";
test(name, () => {
expect(showDate(name, map, date)).toBe("27/09/2024 @ 10:59:27");
});
}
{
const name = "zh-CN";
test(name, () => {
expect(showDate(name, map, date)).toBe("2024/9/27 @ 18:59:27");
});
}
});