You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Add jump to date functionality to date headers in timeline v2 (#7339)
Fix https://github.com/vector-im/element-web/issues/7677 Utilizes MSC3030: https://github.com/matrix-org/matrix-doc/pull/3030 https://user-images.githubusercontent.com/558581/150060664-79627573-f4fd-497c-b726-dc3485854bd0.png
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user