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:
Kerry 2023-02-03 10:39:23 +13:00 committed by GitHub
parent 544baa30ed
commit ebb8408f28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 572 additions and 7 deletions

View file

@ -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");
});
});