fix ts errors in TimelineEventStore unit tests

This commit is contained in:
Bruno Windels 2021-09-28 14:20:54 +02:00
parent ec2f1b9833
commit e31d3abc97

View File

@ -320,6 +320,7 @@ export class TimelineEventStore {
import {createMockStorage} from "../../../../mocks/Storage"; import {createMockStorage} from "../../../../mocks/Storage";
import {createEvent, withTextBody} from "../../../../mocks/event.js"; import {createEvent, withTextBody} from "../../../../mocks/event.js";
import {createEventEntry} from "../../../room/timeline/persistence/common.js"; import {createEventEntry} from "../../../room/timeline/persistence/common.js";
import {Instance as logItem} from "../../../../logging/NullLogger.js";
export function tests() { export function tests() {
@ -366,15 +367,16 @@ export function tests() {
const txn = await storage.readWriteTxn([storage.storeNames.timelineEvents]); const txn = await storage.readWriteTxn([storage.storeNames.timelineEvents]);
let eventKey = EventKey.defaultFragmentKey(109); let eventKey = EventKey.defaultFragmentKey(109);
for (const insertedId of insertedIds) { for (const insertedId of insertedIds) {
assert(await txn.timelineEvents.tryInsert(createEventEntry(eventKey.nextKey(), roomId, createEventWithId(insertedId)))); const entry = createEventEntry(eventKey.nextKey(), roomId, createEventWithId(insertedId));
assert(await txn.timelineEvents.tryInsert(entry, logItem));
eventKey = eventKey.nextKey(); eventKey = eventKey.nextKey();
} }
const eventKeyMap = await txn.timelineEvents.getEventKeysForIds(roomId, checkedIds); const eventKeyMap = await txn.timelineEvents.getEventKeysForIds(roomId, checkedIds);
assert.equal(eventKeyMap.size, 2); assert.equal(eventKeyMap.size, 2);
const eventKey1 = eventKeyMap.get("$Oil2Afq2cBLqMAeJTAHjA3Is9T5Wmaa2ogVRlFJ_gzE"); const eventKey1 = eventKeyMap.get("$Oil2Afq2cBLqMAeJTAHjA3Is9T5Wmaa2ogVRlFJ_gzE")!;
assert.equal(eventKey1.fragmentId, 109); assert.equal(eventKey1.fragmentId, 109);
assert.equal(eventKey1.eventIndex, 0x80000001); assert.equal(eventKey1.eventIndex, 0x80000001);
const eventKey2 = eventKeyMap.get("$vdLgAnwjHj0cicU3MA4ynLHUBGOIFhvvksY3loqzjF"); const eventKey2 = eventKeyMap.get("$vdLgAnwjHj0cicU3MA4ynLHUBGOIFhvvksY3loqzjF")!;
assert.equal(eventKey2.fragmentId, 109); assert.equal(eventKey2.fragmentId, 109);
assert.equal(eventKey2.eventIndex, 0x80000002); assert.equal(eventKey2.eventIndex, 0x80000002);
} }