You've already forked element-web
mirror of
https://github.com/element-hq/element-web.git
synced 2025-11-29 21:23:11 +03:00
Poll history - read only list of polls in current timeline (#10055)
* add settings while under development * very basic tests for roomsummarycard * empty poll history dialog and option in room summary * pollS history in settings * render an ugly list of polls in current timeline * readonly poll history list items * fix scroll window * use short year code in date format, tidy * no results message + tests * strict fix * mock intldatetimeformat for stable date formatting * extract date format fn into date-utils * jsdoc
This commit is contained in:
@@ -21,8 +21,9 @@ import {
|
||||
formatFullDateNoDayISO,
|
||||
formatTimeLeft,
|
||||
formatPreciseDuration,
|
||||
formatLocalDateShort,
|
||||
} from "../../src/DateUtils";
|
||||
import { REPEATABLE_DATE } from "../test-utils";
|
||||
import { REPEATABLE_DATE, mockIntlDateTimeFormat, unmockIntlDateTimeFormat } from "../test-utils";
|
||||
|
||||
describe("formatSeconds", () => {
|
||||
it("correctly formats time with hours", () => {
|
||||
@@ -137,3 +138,22 @@ describe("formatTimeLeft", () => {
|
||||
expect(formatTimeLeft(seconds)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatLocalDateShort()", () => {
|
||||
afterAll(() => {
|
||||
unmockIntlDateTimeFormat();
|
||||
});
|
||||
const timestamp = new Date("Fri Dec 17 2021 09:09:00 GMT+0100 (Central European Standard Time)").getTime();
|
||||
it("formats date correctly by locale", () => {
|
||||
// format is DD/MM/YY
|
||||
mockIntlDateTimeFormat("en-UK");
|
||||
expect(formatLocalDateShort(timestamp)).toEqual("17/12/21");
|
||||
|
||||
// US date format is MM/DD/YY
|
||||
mockIntlDateTimeFormat("en-US");
|
||||
expect(formatLocalDateShort(timestamp)).toEqual("12/17/21");
|
||||
|
||||
mockIntlDateTimeFormat("de-DE");
|
||||
expect(formatLocalDateShort(timestamp)).toEqual("17.12.21");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user