Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/makeDocumentProjection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,35 @@
}
})

it("should not share state between projections of a handle and its clone", () => {
const {repo, handle} = setup()
const clone = repo.clone(handle)

return createRoot(dispose => {
const source = makeDocumentProjection<ExampleDoc>(handle)
const cloned = makeDocumentProjection<ExampleDoc>(clone)

expect(source.array).not.toBe(cloned.array)

Check failure on line 286 in test/makeDocumentProjection.test.tsx

View workflow job for this annotation

GitHub Actions / build (22.x)

test/makeDocumentProjection.test.tsx > makeDocumentProjection > should not share state between projections of a handle and its clone

AssertionError: expected [ 1, 2, 3 ] not to be [ 1, 2, 3 ] // Object.is equality Compared values have no visual difference. ❯ test/makeDocumentProjection.test.tsx:286:29 ❯ updateFn node_modules/.pnpm/solid-js@1.9.13/node_modules/solid-js/dist/dev.js:197:17 ❯ runUpdates node_modules/.pnpm/solid-js@1.9.13/node_modules/solid-js/dist/dev.js:862:17 ❯ createRoot node_modules/.pnpm/solid-js@1.9.13/node_modules/solid-js/dist/dev.js:202:12 ❯ test/makeDocumentProjection.test.tsx:282:10

const done = testEffect(done => {
createEffect((run: number = 0) => {
if (run == 0) {
expect(source.array).toEqual([1, 2, 3])
expect(cloned.array).toEqual([1, 2, 3])
clone.change(doc => doc.array.push(4))
} else if (run == 1) {
expect(cloned.array).toEqual([1, 2, 3, 4])
expect(source.array).toEqual([1, 2, 3])
done()
}
return run + 1
})
})

return done.finally(dispose)
})
})

it("reconciles from the new scoped value when scopeReplaced fires", async () => {
const {handle} = setup()
type Project = ExampleDoc["projects"][number]
Expand Down
Loading