Skip to content

Commit cc4c8ae

Browse files
committed
Add a reproduction of the issue reported in #488
This test is not in the right place, but I'm not sure where the problem is yet.
1 parent aeb826b commit cc4c8ae

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/automerge-repo-react-hooks/test/useRepo.test.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Repo } from "@automerge/automerge-repo"
2-
import { render } from "@testing-library/react"
2+
import { render, waitFor } from "@testing-library/react"
33
import React from "react"
44
import { describe, expect, test, vi } from "vitest"
55
import { RepoContext, useRepo } from "../src/useRepo.js"
6+
import { setupPairedRepos } from "./testSetup.js"
67

78
describe("useRepo", () => {
89
const Component = ({ onRepo }: { onRepo: (repo: Repo) => void }) => {
@@ -30,4 +31,17 @@ describe("useRepo", () => {
3031
render(<Component onRepo={onRepo} />, { wrapper })
3132
expect(onRepo).toHaveBeenLastCalledWith(repo)
3233
})
34+
35+
test("should synchronize empty documents", async () => {
36+
const { repoCreator, repoFinder } = setupPairedRepos();
37+
38+
const handle = repoCreator.create({});
39+
40+
await waitFor(async () => {
41+
repoFinder.find(handle.documentId);
42+
})
43+
44+
const finderHandle = await repoFinder.find(handle.documentId);
45+
expect(finderHandle.doc).toEqual(handle.doc);
46+
})
3347
})

0 commit comments

Comments
 (0)