Add tests

This commit is contained in:
Adria Navarro 2024-03-06 00:20:42 +01:00
parent 355dea5b05
commit 8f486e7bfc
1 changed files with 22 additions and 0 deletions

View File

@ -187,4 +187,26 @@ describe("redis", () => {
) )
}) })
}) })
describe("deleteIfValue", () => {
it("can delete if the value matches", async () => {
const key = structures.uuid()
const value = generator.word()
await redis.store(key, value)
await redis.deleteIfValue(key, value)
expect(await redis.get(key)).toBeNull()
})
it("will not delete if the value does not matches", async () => {
const key = structures.uuid()
const value = generator.word()
await redis.store(key, value)
await redis.deleteIfValue(key, generator.word())
expect(await redis.get(key)).toEqual(value)
})
})
}) })