diff --git a/src/Model.test.ts b/src/Model.test.ts index 29ca8fe6..3f06bc86 100644 --- a/src/Model.test.ts +++ b/src/Model.test.ts @@ -66,7 +66,6 @@ let simpleTestData: TestData = { interface ModelTestContext extends ModelOptions { streams: IStreamFactory; - channelName: string; } const modelStatePromise = (model: Model, state: ModelState) => @@ -142,8 +141,11 @@ describe('Model', () => { const ready = model.$register({ $sync: sync }); await modelStatePromise(model, 'preparing'); completeSync(); + await ready; await modelStatePromise(model, 'ready'); + await expect(ready).resolves.toEqual({ current: 'ready', previous: 'preparing', reason: undefined }); + expect(sync).toHaveBeenCalledOnce(); expect(model.optimistic).toEqual(simpleTestData); expect(model.confirmed).toEqual(simpleTestData); @@ -155,10 +157,10 @@ describe('Model', () => { completeSync = resolve; }); - const resyned = model.$sync(); + const resynced = model.$sync(); await modelStatePromise(model, 'preparing'); completeSync(); - await resyned; + await resynced; await modelStatePromise(model, 'ready'); expect(sync).toHaveBeenCalledTimes(2); diff --git a/src/Model.ts b/src/Model.ts index b5d8541e..9b32456d 100644 --- a/src/Model.ts +++ b/src/Model.ts @@ -45,7 +45,7 @@ export default class Model extends EventEmitter = async () => { + private syncFunc: SyncFunc = async () => { throw new Error('sync func not registered'); }; private merge?: MergeFunc; @@ -119,7 +119,7 @@ export default class Model extends EventEmitter { @@ -186,7 +186,7 @@ export default class Model extends EventEmitter extends EventEmitter