1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Add same key tests

This commit is contained in:
Adria Navarro 2024-03-06 15:37:38 +01:00
parent 4ce85cde1a
commit a44faad046

View file

@ -256,5 +256,30 @@ describe("docWritethrough", () => {
)
})
})
it("patches will execute in order", async () => {
let incrementalValue = 0
const keyToOverride = generator.word()
async function incrementalPatches(count: number) {
for (let i = 0; i < count; i++) {
await docWritethrough.patch({ [keyToOverride]: incrementalValue++ })
}
}
await config.doInTenant(async () => {
await incrementalPatches(5)
await waitForQueueCompletion()
expect(await db.get(documentId)).toEqual(
expect.objectContaining({ [keyToOverride]: 5 })
)
await incrementalPatches(40)
await waitForQueueCompletion()
expect(await db.get(documentId)).toEqual(
expect.objectContaining({ [keyToOverride]: 45 })
)
})
})
})
})