Skip to content

Commit

Permalink
Add tests for booleans in redis (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Feb 15, 2023
1 parent cd96c42 commit 4fb02fa
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/RedisCache.spec.ts
Expand Up @@ -122,6 +122,40 @@ describe('RedisCache', () => {
expect(value2).toEqual({ value: 'value2' })
})

it('sets non-json boolean values correctly', async () => {
const cache = new RedisCache(redis, {
json: false,
prefix: 'cache',
})
await cache.set('key', true)
await cache.set('key2', false)

const value1 = await cache.get('key')
const value2 = await cache.get('key2')
const value3 = await cache.get('key3')

expect(value1).toEqual('true')
expect(value2).toEqual('false')
expect(value3).toEqual(undefined)
})

it('sets json boolean values correctly', async () => {
const cache = new RedisCache(redis, {
json: true,
prefix: 'cache',
})
await cache.set('key', true)
await cache.set('key2', false)

const value1 = await cache.get('key')
const value2 = await cache.get('key2')
const value3 = await cache.get('key3')

expect(value1).toEqual(true)
expect(value2).toEqual(false)
expect(value3).toEqual(undefined)
})

it('sets expiration correctly', async () => {
const cache = new RedisCache(redis, {
json: true,
Expand Down

0 comments on commit 4fb02fa

Please sign in to comment.