1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00
Eric Eastwood
2022-01-27 16:32:12 -06:00
committed by GitHub
parent efa1667d7e
commit 7fa27f5834
17 changed files with 630 additions and 44 deletions

View File

@@ -64,7 +64,11 @@ describe("DateSeparator", () => {
beforeEach(() => {
global.Date = MockDate as unknown as DateConstructor;
(SettingsStore.getValue as jest.Mock).mockReturnValue(true);
(SettingsStore.getValue as jest.Mock) = jest.fn((arg) => {
if (arg === UIFeature.TimelineEnableRelativeDates) {
return true;
}
});
});
afterAll(() => {
@@ -89,10 +93,28 @@ describe("DateSeparator", () => {
describe('when Settings.TimelineEnableRelativeDates is falsy', () => {
beforeEach(() => {
(SettingsStore.getValue as jest.Mock).mockReturnValue(false);
(SettingsStore.getValue as jest.Mock) = jest.fn((arg) => {
if (arg === UIFeature.TimelineEnableRelativeDates) {
return false;
}
});
});
it.each(testCases)('formats date in full when current time is %s', (_d, ts) => {
expect(getComponent({ ts, forExport: false }).text()).toEqual(formatFullDateNoTime(new Date(ts)));
});
});
describe('when feature_jump_to_date is enabled', () => {
beforeEach(() => {
(SettingsStore.getValue as jest.Mock) = jest.fn((arg) => {
if (arg === "feature_jump_to_date") {
return true;
}
});
});
it('renders the date separator correctly', () => {
const component = getComponent();
expect(component).toMatchSnapshot();
});
});
});