mirror of
https://github.com/element-hq/element-web
synced 2024-11-22 17:25:50 +03:00
ebb8408f28
* 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
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
/*
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
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();
|
|
};
|