You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +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:
@ -15,3 +15,21 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
export const REPEATABLE_DATE = new Date(2022, 10, 17, 16, 58, 32, 517);
|
||||
|
||||
// allow setting default locale and set timezone
|
||||
// defaults to en-GB / Europe/London
|
||||
// so tests run the same everywhere
|
||||
export const mockIntlDateTimeFormat = (defaultLocale = "en-GB", defaultTimezone = "Europe/London"): void => {
|
||||
// unmock so we can use real DateTimeFormat in mockImplementation
|
||||
if (jest.isMockFunction(global.Intl.DateTimeFormat)) {
|
||||
unmockIntlDateTimeFormat();
|
||||
}
|
||||
const DateTimeFormat = Intl.DateTimeFormat;
|
||||
jest.spyOn(global.Intl, "DateTimeFormat").mockImplementation(
|
||||
(locale, options) => new DateTimeFormat(locale || defaultLocale, { ...options, timeZone: defaultTimezone }),
|
||||
);
|
||||
};
|
||||
|
||||
export const unmockIntlDateTimeFormat = (): void => {
|
||||
jest.spyOn(global.Intl, "DateTimeFormat").mockRestore();
|
||||
};
|
||||
|
Reference in New Issue
Block a user