-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show leading zeros on minutes in shared link expiration display
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { formatDate, formatDateLong } from "./date-helpers"; | ||
|
||
describe("formatDate", () => { | ||
test("should format date correctly", () => { | ||
const result = formatDate("2023-11-14T13:14:00Z"); | ||
expect(result).toBe("2023-10-2"); // Note: getMonth() is zero-based, getDay() returns day of the week | ||
}); | ||
|
||
test("should handle invalid date", () => { | ||
const result = formatDate("invalid-date"); | ||
expect(result).toBe("NaN-NaN-NaN"); | ||
}); | ||
}); | ||
|
||
describe("formatDateLong", () => { | ||
test("should format date correctly in long format", () => { | ||
const result = formatDateLong("2023-11-14T13:14:00Z"); | ||
expect(result).toBe("November 14, 2023, 1:14pm"); | ||
}); | ||
|
||
test("should return empty string if date is undefined", () => { | ||
const result = formatDateLong(undefined); | ||
expect(result).toBe(""); | ||
}); | ||
|
||
test("should format time correctly with leading zeroes in minutes", () => { | ||
const result = formatDateLong("2023-11-14T01:04:00Z"); | ||
expect(result).toBe("November 14, 2023, 1:04am"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters