From 3f4fab7476fa973f6e0c86b3da725ff5cf3cbd41 Mon Sep 17 00:00:00 2001 From: Mitsunee <19474909+Mitsunee@users.noreply.github.com> Date: Sat, 23 Nov 2024 01:59:26 +0100 Subject: [PATCH] add: dedicated tests for padding in formatTime --- tests/formatTime.test.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/formatTime.test.ts b/tests/formatTime.test.ts index adb1629..2f9c5e0 100644 --- a/tests/formatTime.test.ts +++ b/tests/formatTime.test.ts @@ -4,12 +4,12 @@ import { formatTime } from "../src/formatTime"; import { getLocalTimezone } from "./utils/getLocalTimezone"; const localTz = getLocalTimezone(); -const sampleDate = new Date(`2024-11-23T00:17:32.123${localTz}`); +const sampleDate = new Date(`2024-11-23T00:17:32.023${localTz}`); console.log( `Created sample time with offset ${localTz}: Local: ${sampleDate.toLocaleString()} - UTC: ${sampleDate.toLocaleString(undefined, { timeZone: "UTC" })}` + UTC: ${sampleDate.toLocaleString(undefined, { timeZone: "UTC" })}\n` ); test("basic date variables", () => { @@ -25,6 +25,19 @@ test("basic date variables", () => { ); }); +test("padding", () => { + assert.is( + formatTime("%ms%", sampleDate, false, 24), + "23", + "test unpadded %ms%" + ); + assert.is( + formatTime("%#ms%", sampleDate, false, 24), + "023", + "test padded %ms%" + ); +}); + test("12hour notation", () => { assert.is( formatTime("%time%", sampleDate, false, 12),