Skip to content

Commit

Permalink
test: improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 8, 2024
1 parent 527dca3 commit 8241a01
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const createKeys = require('./keys')
const createPlans = require('./plans')

module.exports = ({ serialize = JSONB.stringify, deserialize = JSONB.parse, redis = new Map() } = {}) => {
if (!redis) throw TypeError('The argument `store` is required.')
const plans = createPlans({ serialize, deserialize, redis })
const keys = createKeys({ serialize, deserialize, redis, plans })
return { keys, plans }
Expand Down
3 changes: 2 additions & 1 deletion src/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ module.exports = ({ serialize, deserialize, plans, redis } = {}) => {
assert(plan === null, `The key \`${keyId}\` is associated with the plan \`${getKey.plan}\``)
}
const isDeleted = (await redis.del(getKey(keyId, { verify: true }))) === 1
return assert(isDeleted, `The key \`${keyId}\` does not exist.`) || isDeleted
assert(isDeleted, `The key \`${keyId}\` does not exist.`)
return isDeleted
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/plans.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ module.exports = ({ serialize, deserialize, redis } = {}) => {
*/
const del = async planId => {
const isDeleted = (await redis.del(getKey(planId, { validate: true }))) === 1
return assert(isDeleted, `The plan \`${planId}\` does not exist.`) || isDeleted
assert(isDeleted, `The plan \`${planId}\` does not exist.`)
return isDeleted
}

/**
Expand Down
1 change: 0 additions & 1 deletion test/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const { keys, plans } = openkey({ redis: new Redis() })

test.beforeEach(async () => {
const keys = await redis.keys(`${KEY_PREFIX}*`)

if (keys.length > 0) await redis.del(keys)
})

Expand Down

0 comments on commit 8241a01

Please sign in to comment.