From 06e43d9ee3e77d99d7b25e53ee939e8be7552e0c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Sat, 14 Mar 2020 21:38:37 +0100 Subject: [PATCH] fix all tests --- src/matrix/room/summary.js | 6 ++++-- src/matrix/session.js | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/matrix/room/summary.js b/src/matrix/room/summary.js index c5e264f2..b29ee9bd 100644 --- a/src/matrix/room/summary.js +++ b/src/matrix/room/summary.js @@ -162,9 +162,11 @@ export function tests() { return { "membership trigger change": function(assert) { const summary = new RoomSummary("id"); - const changes = summary.writeSync({}, "join"); + let written = false; + const changes = summary.writeSync({}, "join", {roomSummary: {set: () => { written = true; }}}); assert(changes); - assert(changes.changed); + assert(written); + assert.equal(changes.membership, "join"); } } } diff --git a/src/matrix/session.js b/src/matrix/session.js index 63b2b03c..33cd16aa 100644 --- a/src/matrix/session.js +++ b/src/matrix/session.js @@ -107,7 +107,7 @@ export default class Session { } export function tests() { - function createStorageMock(session, pendingEvents) { + function createStorageMock(session, pendingEvents = []) { return { readTxn() { return Promise.resolve({ @@ -120,9 +120,15 @@ export function tests() { getAll() { return Promise.resolve(pendingEvents); } + }, + roomSummary: { + getAll() { + return Promise.resolve([]); + } } }); - } + }, + storeNames: {} }; } @@ -131,25 +137,25 @@ export function tests() { const session = new Session({storage: createStorageMock({ syncToken: "a", syncFilterId: 5, - })}); + }), sessionInfo: {userId: ""}}); await session.load(); let txnSetCalled = false; const syncTxn = { session: { set({syncToken, syncFilterId}) { txnSetCalled = true; - assert.equals(syncToken, "b"); - assert.equals(syncFilterId, 6); + assert.equal(syncToken, "b"); + assert.equal(syncFilterId, 6); } } }; const newSessionData = session.writeSync("b", 6, {}, syncTxn); assert(txnSetCalled); - assert.equals(session.syncToken, "a"); - assert.equals(session.syncFilterId, 5); + assert.equal(session.syncToken, "a"); + assert.equal(session.syncFilterId, 5); session.afterSync(newSessionData); - assert.equals(session.syncToken, "b"); - assert.equals(session.syncFilterId, 6); + assert.equal(session.syncToken, "b"); + assert.equal(session.syncFilterId, 6); } } }