You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
Replace jshint with eslint and add lots of rules
Fix eslint errors accordingly
This commit is contained in:
@ -1,27 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var config = require("../lib/config");
|
||||
var config = require('../lib/config');
|
||||
var helper = require('../helper');
|
||||
var redis = config.redis;
|
||||
|
||||
describe("The 'select' method", function () {
|
||||
|
||||
helper.allTests(function(parser, ip, args) {
|
||||
helper.allTests(function (parser, ip, args) {
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
describe("when not connected", function () {
|
||||
describe('using ' + parser + ' and ' + ip, function () {
|
||||
describe('when not connected', function () {
|
||||
var client;
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(null, args);
|
||||
client.once("ready", function () {
|
||||
client.once('ready', function () {
|
||||
client.quit();
|
||||
});
|
||||
client.on('end', done);
|
||||
});
|
||||
|
||||
it("returns an error if redis is not connected", function (done) {
|
||||
it('returns an error if redis is not connected', function (done) {
|
||||
var buffering = client.select(1, function (err, res) {
|
||||
assert(err.message.match(/The connection has already been closed/));
|
||||
done();
|
||||
@ -30,12 +30,12 @@ describe("The 'select' method", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("when connected", function () {
|
||||
describe('when connected', function () {
|
||||
var client;
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(null, args);
|
||||
client.once("ready", function () {
|
||||
client.once('ready', function () {
|
||||
client.flushdb(done);
|
||||
});
|
||||
});
|
||||
@ -44,32 +44,32 @@ describe("The 'select' method", function () {
|
||||
client.end(true);
|
||||
});
|
||||
|
||||
it("changes the database and calls the callback", function (done) {
|
||||
it('changes the database and calls the callback', function (done) {
|
||||
// default value of null means database 0 will be used.
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
var buffering = client.SELECT(1, function (err, res) {
|
||||
helper.isNotError()(err, res);
|
||||
assert.strictEqual(client.selected_db, 1, "db should be 1 after select");
|
||||
assert.strictEqual(client.selected_db, 1, 'db should be 1 after select');
|
||||
done();
|
||||
});
|
||||
assert(typeof buffering === 'boolean');
|
||||
});
|
||||
|
||||
describe("and a callback is specified", function () {
|
||||
describe("with a valid db index", function () {
|
||||
it("selects the appropriate database", function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
describe('and a callback is specified', function () {
|
||||
describe('with a valid db index', function () {
|
||||
it('selects the appropriate database', function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
client.select(1, function (err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(client.selected_db, 1, "we should have selected the new valid DB");
|
||||
assert.equal(client.selected_db, 1, 'we should have selected the new valid DB');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("with an invalid db index", function () {
|
||||
it("returns an error", function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
describe('with an invalid db index', function () {
|
||||
it('returns an error', function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
client.select(9999, function (err) {
|
||||
assert.equal(err.code, 'ERR');
|
||||
assert.equal(err.message, 'ERR invalid DB index');
|
||||
@ -79,21 +79,21 @@ describe("The 'select' method", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("and no callback is specified", function () {
|
||||
describe("with a valid db index", function () {
|
||||
it("selects the appropriate database", function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
describe('and no callback is specified', function () {
|
||||
describe('with a valid db index', function () {
|
||||
it('selects the appropriate database', function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
client.select(1);
|
||||
setTimeout(function () {
|
||||
assert.equal(client.selected_db, 1, "we should have selected the new valid DB");
|
||||
assert.equal(client.selected_db, 1, 'we should have selected the new valid DB');
|
||||
return done();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with an invalid db index", function () {
|
||||
it("emits an error when callback not provided", function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
describe('with an invalid db index', function () {
|
||||
it('emits an error when callback not provided', function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
|
||||
client.on('error', function (err) {
|
||||
assert.strictEqual(err.command, 'SELECT');
|
||||
@ -106,9 +106,9 @@ describe("The 'select' method", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("reconnection occurs", function () {
|
||||
it("selects the appropriate database after a reconnect", function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, "default db should be undefined");
|
||||
describe('reconnection occurs', function () {
|
||||
it('selects the appropriate database after a reconnect', function (done) {
|
||||
assert.strictEqual(client.selected_db, undefined, 'default db should be undefined');
|
||||
client.select(3);
|
||||
client.set('foo', 'bar', function () {
|
||||
client.stream.destroy();
|
||||
|
Reference in New Issue
Block a user