You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
test fixup
This commit is contained in:
@@ -1,69 +1,69 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var config = require('../lib/config')
|
||||
var helper = require('../helper')
|
||||
var redis = config.redis
|
||||
var uuid = require('uuid')
|
||||
const assert = require('assert')
|
||||
const config = require('../lib/config')
|
||||
const helper = require('../helper')
|
||||
const redis = config.redis
|
||||
const uuid = require('uuid')
|
||||
|
||||
describe('The \'flushdb\' method', function () {
|
||||
helper.allTests(function (ip, args) {
|
||||
describe('using ' + ip, function () {
|
||||
var key, key2
|
||||
describe('The \'flushdb\' method', () => {
|
||||
helper.allTests((ip, args) => {
|
||||
describe(`using ${ip}`, () => {
|
||||
let key, key2
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(() => {
|
||||
key = uuid.v4()
|
||||
key2 = uuid.v4()
|
||||
})
|
||||
|
||||
describe('when not connected', function () {
|
||||
var client
|
||||
describe('when not connected', () => {
|
||||
let client
|
||||
|
||||
beforeEach(function (done) {
|
||||
beforeEach((done) => {
|
||||
client = redis.createClient.apply(null, args)
|
||||
client.once('ready', function () {
|
||||
client.once('ready', () => {
|
||||
client.quit()
|
||||
})
|
||||
client.on('end', done)
|
||||
})
|
||||
|
||||
it('reports an error', function (done) {
|
||||
client.flushdb(function (err, res) {
|
||||
it('reports an error', (done) => {
|
||||
client.flushdb((err, res) => {
|
||||
assert(err.message.match(/The connection is already closed/))
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when connected', function () {
|
||||
var client
|
||||
describe('when connected', () => {
|
||||
let client
|
||||
|
||||
beforeEach(function (done) {
|
||||
beforeEach((done) => {
|
||||
client = redis.createClient.apply(null, args)
|
||||
client.once('ready', function () {
|
||||
client.once('ready', () => {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(() => {
|
||||
client.end(true)
|
||||
})
|
||||
|
||||
describe('when there is data in Redis', function () {
|
||||
beforeEach(function (done) {
|
||||
describe('when there is data in Redis', () => {
|
||||
beforeEach((done) => {
|
||||
client.mset(key, uuid.v4(), key2, uuid.v4(), helper.isNotError())
|
||||
client.dbsize([], function (err, res) {
|
||||
client.dbsize([], (err, res) => {
|
||||
helper.isType.positiveNumber()(err, res)
|
||||
assert.strictEqual(res, 2, 'Two keys should have been inserted')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('deletes all the keys', function (done) {
|
||||
client.flushdb(function (err, res) {
|
||||
it('deletes all the keys', (done) => {
|
||||
client.flushdb((err, res) => {
|
||||
assert.strictEqual(err, null)
|
||||
assert.strictEqual(res, 'OK')
|
||||
client.mget(key, key2, function (err, res) {
|
||||
client.mget(key, key2, (err, res) => {
|
||||
assert.strictEqual(null, err, 'Unexpected error returned')
|
||||
assert.strictEqual(true, Array.isArray(res), 'Results object should be an array.')
|
||||
assert.strictEqual(2, res.length, 'Results array should have length 2.')
|
||||
@@ -74,16 +74,16 @@ describe('The \'flushdb\' method', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('results in a db size of zero', function (done) {
|
||||
client.flushdb(function (err, res) {
|
||||
it('results in a db size of zero', (done) => {
|
||||
client.flushdb((err, res) => {
|
||||
assert.strictEqual(err, null)
|
||||
client.dbsize([], helper.isNumber(0, done))
|
||||
})
|
||||
})
|
||||
|
||||
it('results in a db size of zero without a callback', function (done) {
|
||||
it('results in a db size of zero without a callback', (done) => {
|
||||
client.flushdb()
|
||||
setTimeout(function () {
|
||||
setTimeout(() => {
|
||||
client.dbsize(helper.isNumber(0, done))
|
||||
}, 25)
|
||||
})
|
||||
|
Reference in New Issue
Block a user