From 2a92220aeb15369d4b14cb0a2d297b2339885fa5 Mon Sep 17 00:00:00 2001 From: Geoffrey Litt Date: Mon, 5 Aug 2024 15:46:40 -0400 Subject: [PATCH] failing test: loading empty doc from network --- packages/automerge-repo/test/DocHandle.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/automerge-repo/test/DocHandle.test.ts b/packages/automerge-repo/test/DocHandle.test.ts index a82bbaa98..3d9257176 100644 --- a/packages/automerge-repo/test/DocHandle.test.ts +++ b/packages/automerge-repo/test/DocHandle.test.ts @@ -153,6 +153,22 @@ describe("DocHandle", () => { assert.equal(doc?.foo, "bar") }) + it("should become ready if the network returns an empty document", async () => { + const handle = new DocHandle(TEST_ID) + + // we don't have it in storage, so we request it from the network + handle.request() + + // simulate updating from the network with an empty document + handle.update(doc => { + return A.init() + }) + + const doc = await handle.doc() + assert.equal(handle.isReady(), true) + assert.deepEqual(doc, {}) + }) + it("should emit a change message when changes happen", async () => { const handle = setup()