1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/test/commands/del.spec.js
2017-05-19 06:14:29 +02:00

53 lines
1.5 KiB
JavaScript

'use strict'
const config = require('../lib/config')
const helper = require('../helper')
const redis = config.redis
describe('The \'del\' method', () => {
helper.allTests((ip, args) => {
describe(`using ${ip}`, () => {
let client
beforeEach(() => {
client = redis.createClient.apply(null, args)
return client.flushdb()
})
it('allows a single key to be deleted', () => {
return Promise.all([
client.set('foo', 'bar'),
client.del('foo').then(helper.isNumber(1)),
client.get('foo').then(helper.isNull())
])
})
it('allows del to be called on a key that does not exist', () => {
return client.del('foo').then(helper.isNumber(0))
})
it('allows multiple keys to be deleted', () => {
return Promise.all([
client.mset('foo', 'bar', 'apple', 'banana'),
client.del('foo', 'apple').then(helper.isNumber(2)),
client.get('foo').then(helper.isNull()),
client.get('apple').then(helper.isNull())
])
})
it('allows multiple keys to be deleted with the array syntax', () => {
return Promise.all([
client.mset('foo', 'bar', 'apple', 'banana'),
client.del(['foo', 'apple']).then(helper.isNumber(2)),
client.get('foo').then(helper.isNull()),
client.get('apple').then(helper.isNull())
])
})
afterEach(() => {
client.end(true)
})
})
})
})