Add extra tests
This commit is contained in:
parent
61d73b1f59
commit
643d57b583
|
@ -81,5 +81,38 @@ describe("DatabaseImpl", () => {
|
|||
})
|
||||
}
|
||||
})
|
||||
|
||||
it("keeps existing createdAt", async () => {
|
||||
const ids = generator.unique(() => generator.guid(), 2)
|
||||
|
||||
await db.bulkDocs(ids.map(id => ({ _id: id })))
|
||||
tk.travel(100)
|
||||
|
||||
const newDocs = generator
|
||||
.unique(() => generator.guid(), 3)
|
||||
.map(id => ({ _id: id }))
|
||||
const docsToUpdate = await Promise.all(
|
||||
ids.map(async id => ({ ...(await db.get(id)), newValue: 123 }))
|
||||
)
|
||||
await db.bulkDocs([...newDocs, ...docsToUpdate])
|
||||
|
||||
for (const { _id } of docsToUpdate) {
|
||||
expect(await db.get(_id)).toEqual({
|
||||
_id,
|
||||
_rev: expect.any(String),
|
||||
newValue: 123,
|
||||
createdAt: initialTime.toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
}
|
||||
for (const { _id } of newDocs) {
|
||||
expect(await db.get(_id)).toEqual({
|
||||
_id,
|
||||
_rev: expect.any(String),
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue