mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-30 13:52:44 -08:00
test: scope timeline helper consistently
This commit is contained in:
1 parent
03277c0bd6
commit
2b78d0bc3a
1 file changed
+19
-19
@@ -78,6 +78,25 @@ function makeManager(mx: ReturnType<typeof makeMockMx>): SlidingSyncManager {
|
||||
return new SlidingSyncManager(mx, 'https://sliding.example.com');
|
||||
}
|
||||
|
||||
function makeRoomWithTimeline(
|
||||
eventCount: number,
|
||||
statuses: Array<string | null> = [],
|
||||
backwardPaginationToken: string | null = 'back-token'
|
||||
) {
|
||||
const events = Array.from({ length: eventCount }, (_, i) => ({
|
||||
status: statuses[i] ?? null,
|
||||
}));
|
||||
return {
|
||||
getLiveTimeline: vi.fn<
|
||||
() => { getEvents: () => typeof events; getPaginationToken: () => string | null }
|
||||
>(() => ({
|
||||
getEvents: () => events,
|
||||
getPaginationToken: () => backwardPaginationToken,
|
||||
})),
|
||||
resetLiveTimeline: vi.fn<() => void>(),
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
localStorage.clear();
|
||||
@@ -984,25 +1003,6 @@ describe('SlidingSyncManager local membership reconciliation', () => {
|
||||
});
|
||||
|
||||
describe('SlidingSyncManager timeline pruning on room deactivation', () => {
|
||||
function makeRoomWithTimeline(
|
||||
eventCount: number,
|
||||
statuses: Array<string | null> = [],
|
||||
backwardPaginationToken: string | null = 'back-token'
|
||||
) {
|
||||
const events = Array.from({ length: eventCount }, (_, i) => ({
|
||||
status: statuses[i] ?? null,
|
||||
}));
|
||||
return {
|
||||
getLiveTimeline: vi.fn<
|
||||
() => { getEvents: () => typeof events; getPaginationToken: () => string | null }
|
||||
>(() => ({
|
||||
getEvents: () => events,
|
||||
getPaginationToken: () => backwardPaginationToken,
|
||||
})),
|
||||
resetLiveTimeline: vi.fn<() => void>(),
|
||||
};
|
||||
}
|
||||
|
||||
it('prunes the live timeline when it exceeds the threshold, preserving the backward pagination token', () => {
|
||||
const roomId = '!over:example.com';
|
||||
const room = makeRoomWithTimeline(151);
|
||||
|
||||
Reference in new issue
Block a user