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,60 +1,60 @@
|
||||
'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 \'mset\' method', function () {
|
||||
helper.allTests(function (ip, args) {
|
||||
describe('using ' + ip, function () {
|
||||
var key, value, key2, value2
|
||||
describe('The \'mset\' method', () => {
|
||||
helper.allTests((ip, args) => {
|
||||
describe(`using ${ip}`, () => {
|
||||
let key, value, key2, value2
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(() => {
|
||||
key = uuid.v4()
|
||||
value = uuid.v4()
|
||||
key2 = uuid.v4()
|
||||
value2 = 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.mset(key, value, key2, value2, function (err, res) {
|
||||
it('reports an error', (done) => {
|
||||
client.mset(key, value, key2, value2, (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('and a callback is specified', function () {
|
||||
describe('with valid parameters', function () {
|
||||
it('sets the value correctly', function (done) {
|
||||
client.mset(key, value, key2, value2, function (err) {
|
||||
describe('and a callback is specified', () => {
|
||||
describe('with valid parameters', () => {
|
||||
it('sets the value correctly', (done) => {
|
||||
client.mset(key, value, key2, value2, (err) => {
|
||||
if (err) {
|
||||
return done(err)
|
||||
}
|
||||
@@ -64,9 +64,9 @@ describe('The \'mset\' method', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with undefined \'key\' parameter and missing \'value\' parameter', function () {
|
||||
it('reports an error', function (done) {
|
||||
client.mset(undefined, function (err, res) {
|
||||
describe('with undefined \'key\' parameter and missing \'value\' parameter', () => {
|
||||
it('reports an error', (done) => {
|
||||
client.mset(undefined, (err, res) => {
|
||||
helper.isError()(err, null)
|
||||
done()
|
||||
})
|
||||
@@ -74,25 +74,25 @@ describe('The \'mset\' method', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('and no callback is specified', function () {
|
||||
describe('with valid parameters', function () {
|
||||
it('sets the value correctly', function (done) {
|
||||
describe('and no callback is specified', () => {
|
||||
describe('with valid parameters', () => {
|
||||
it('sets the value correctly', (done) => {
|
||||
client.mset(key, value2, key2, value)
|
||||
client.get(key, helper.isString(value2))
|
||||
client.get(key2, helper.isString(value, done))
|
||||
})
|
||||
|
||||
it('sets the value correctly with array syntax', function (done) {
|
||||
it('sets the value correctly with array syntax', (done) => {
|
||||
client.mset([key, value2, key2, value])
|
||||
client.get(key, helper.isString(value2))
|
||||
client.get(key2, helper.isString(value, done))
|
||||
})
|
||||
})
|
||||
|
||||
describe('with undefined \'key\' and missing \'value\' parameter', function () {
|
||||
describe('with undefined \'key\' and missing \'value\' parameter', () => {
|
||||
// this behavior is different from the 'set' behavior.
|
||||
it('emits an error', function (done) {
|
||||
client.on('error', function (err) {
|
||||
it('emits an error', (done) => {
|
||||
client.on('error', (err) => {
|
||||
assert.strictEqual(err.message, 'ERR wrong number of arguments for \'mset\' command')
|
||||
assert.strictEqual(err.name, 'ReplyError')
|
||||
done()
|
||||
|
Reference in New Issue
Block a user