You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Replace jshint with eslint and add lots of rules
Fix eslint errors accordingly
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require("assert");
|
||||
var config = require("./lib/config");
|
||||
var assert = require('assert');
|
||||
var config = require('./lib/config');
|
||||
var helper = require('./helper');
|
||||
var redis = config.redis;
|
||||
|
||||
describe("return_buffers", function () {
|
||||
describe('return_buffers', function () {
|
||||
|
||||
helper.allTests(function(parser, ip, basicArgs) {
|
||||
helper.allTests(function (parser, ip, basicArgs) {
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
describe('using ' + parser + ' and ' + ip, function () {
|
||||
var client;
|
||||
var args = config.configureClient(parser, ip, {
|
||||
return_buffers: true,
|
||||
@@ -30,11 +30,11 @@ describe("return_buffers", function () {
|
||||
assert.strictEqual(msg, 'WARNING: You activated return_buffers and detect_buffers at the same time. The return value is always going to be a buffer.');
|
||||
end();
|
||||
});
|
||||
client.once("error", done);
|
||||
client.once("connect", function () {
|
||||
client.once('error', done);
|
||||
client.once('connect', function () {
|
||||
client.flushdb(function (err) {
|
||||
client.hmset("hash key 2", "key 1", "val 1", "key 2", "val 2");
|
||||
client.set("string key 1", "string value");
|
||||
client.hmset('hash key 2', 'key 1', 'val 1', 'key 2', 'val 2');
|
||||
client.set('string key 1', 'string value');
|
||||
end(err);
|
||||
});
|
||||
});
|
||||
@@ -43,18 +43,18 @@ describe("return_buffers", function () {
|
||||
describe('get', function () {
|
||||
describe('first argument is a string', function () {
|
||||
it('returns a buffer', function (done) {
|
||||
client.get("string key 1", function (err, reply) {
|
||||
client.get('string key 1', function (err, reply) {
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply));
|
||||
assert.strictEqual("<Buffer 73 74 72 69 6e 67 20 76 61 6c 75 65>", reply.inspect());
|
||||
assert.strictEqual('<Buffer 73 74 72 69 6e 67 20 76 61 6c 75 65>', reply.inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a bufffer when executed as part of transaction', function (done) {
|
||||
client.multi().get("string key 1").exec(function (err, reply) {
|
||||
client.multi().get('string key 1').exec(function (err, reply) {
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]));
|
||||
assert.strictEqual("<Buffer 73 74 72 69 6e 67 20 76 61 6c 75 65>", reply[0].inspect());
|
||||
assert.strictEqual('<Buffer 73 74 72 69 6e 67 20 76 61 6c 75 65>', reply[0].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -64,20 +64,20 @@ describe("return_buffers", function () {
|
||||
describe('multi.hget', function () {
|
||||
it('returns buffers', function (done) {
|
||||
client.multi()
|
||||
.hget("hash key 2", "key 1")
|
||||
.hget(new Buffer("hash key 2"), "key 1")
|
||||
.hget("hash key 2", new Buffer("key 2"))
|
||||
.hget("hash key 2", "key 2")
|
||||
.hget('hash key 2', 'key 1')
|
||||
.hget(new Buffer('hash key 2'), 'key 1')
|
||||
.hget('hash key 2', new Buffer('key 2'))
|
||||
.hget('hash key 2', 'key 2')
|
||||
.exec(function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(4, reply.length);
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[1]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[1].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[1].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[2]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[2].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[2].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[3]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[3].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[3].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -86,20 +86,20 @@ describe("return_buffers", function () {
|
||||
describe('batch.hget', function () {
|
||||
it('returns buffers', function (done) {
|
||||
client.batch()
|
||||
.hget("hash key 2", "key 1")
|
||||
.hget(new Buffer("hash key 2"), "key 1")
|
||||
.hget("hash key 2", new Buffer("key 2"))
|
||||
.hget("hash key 2", "key 2")
|
||||
.hget('hash key 2', 'key 1')
|
||||
.hget(new Buffer('hash key 2'), 'key 1')
|
||||
.hget('hash key 2', new Buffer('key 2'))
|
||||
.hget('hash key 2', 'key 2')
|
||||
.exec(function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(4, reply.length);
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[1]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[1].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[1].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[2]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[2].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[2].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[3]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[3].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[3].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -108,7 +108,7 @@ describe("return_buffers", function () {
|
||||
describe('hmget', function () {
|
||||
describe('first argument is a string', function () {
|
||||
it('handles array of strings with undefined values in transaction (repro #344)', function (done) {
|
||||
client.multi().hmget("hash key 2", "key 3", "key 4").exec(function(err, reply) {
|
||||
client.multi().hmget('hash key 2', 'key 3', 'key 4').exec(function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual(2, reply[0].length);
|
||||
@@ -121,39 +121,39 @@ describe("return_buffers", function () {
|
||||
|
||||
describe('first argument is a buffer', function () {
|
||||
it('returns buffers for keys requested', function (done) {
|
||||
client.hmget(new Buffer("hash key 2"), "key 1", "key 2", function (err, reply) {
|
||||
client.hmget(new Buffer('hash key 2'), 'key 1', 'key 2', function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(2, reply.length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[1]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[1].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[1].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it("returns buffers for keys requested in transaction", function (done) {
|
||||
client.multi().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) {
|
||||
it('returns buffers for keys requested in transaction', function (done) {
|
||||
client.multi().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual(2, reply[0].length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0][0]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0][1]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0][0].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0][1].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0][0].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0][1].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it("returns buffers for keys requested in .batch", function (done) {
|
||||
client.batch().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) {
|
||||
it('returns buffers for keys requested in .batch', function (done) {
|
||||
client.batch().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) {
|
||||
assert.strictEqual(true, Array.isArray(reply));
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual(2, reply[0].length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0][0]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0][1]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0][0].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0][1].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0][0].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0][1].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -163,33 +163,33 @@ describe("return_buffers", function () {
|
||||
describe('hgetall', function (done) {
|
||||
describe('first argument is a string', function () {
|
||||
it('returns buffer values', function (done) {
|
||||
client.hgetall("hash key 2", function (err, reply) {
|
||||
assert.strictEqual("object", typeof reply);
|
||||
client.hgetall('hash key 2', function (err, reply) {
|
||||
assert.strictEqual('object', typeof reply);
|
||||
assert.strictEqual(2, Object.keys(reply).length);
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply["key 2"].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns buffer values when executed in transaction', function (done) {
|
||||
client.multi().hgetall("hash key 2").exec(function (err, reply) {
|
||||
client.multi().hgetall('hash key 2').exec(function (err, reply) {
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual("object", typeof reply[0]);
|
||||
assert.strictEqual('object', typeof reply[0]);
|
||||
assert.strictEqual(2, Object.keys(reply[0]).length);
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0]["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0]["key 2"].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0]['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0]['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns buffer values when executed in .batch', function (done) {
|
||||
client.batch().hgetall("hash key 2").exec(function (err, reply) {
|
||||
client.batch().hgetall('hash key 2').exec(function (err, reply) {
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual("object", typeof reply[0]);
|
||||
assert.strictEqual('object', typeof reply[0]);
|
||||
assert.strictEqual(2, Object.keys(reply[0]).length);
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0]["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0]["key 2"].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0]['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0]['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -197,40 +197,40 @@ describe("return_buffers", function () {
|
||||
|
||||
describe('first argument is a buffer', function () {
|
||||
it('returns buffer values', function (done) {
|
||||
client.hgetall(new Buffer("hash key 2"), function (err, reply) {
|
||||
client.hgetall(new Buffer('hash key 2'), function (err, reply) {
|
||||
assert.strictEqual(null, err);
|
||||
assert.strictEqual("object", typeof reply);
|
||||
assert.strictEqual('object', typeof reply);
|
||||
assert.strictEqual(2, Object.keys(reply).length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply["key 1"]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply["key 2"]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply["key 2"].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply['key 1']));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply['key 2']));
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns buffer values when executed in transaction', function (done) {
|
||||
client.multi().hgetall(new Buffer("hash key 2")).exec(function (err, reply) {
|
||||
client.multi().hgetall(new Buffer('hash key 2')).exec(function (err, reply) {
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual("object", typeof reply[0]);
|
||||
assert.strictEqual('object', typeof reply[0]);
|
||||
assert.strictEqual(2, Object.keys(reply[0]).length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0]["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0]["key 2"].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1']));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2']));
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0]['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0]['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns buffer values when executed in .batch', function (done) {
|
||||
client.batch().hgetall(new Buffer("hash key 2")).exec(function (err, reply) {
|
||||
client.batch().hgetall(new Buffer('hash key 2')).exec(function (err, reply) {
|
||||
assert.strictEqual(1, reply.length);
|
||||
assert.strictEqual("object", typeof reply[0]);
|
||||
assert.strictEqual('object', typeof reply[0]);
|
||||
assert.strictEqual(2, Object.keys(reply[0]).length);
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"]));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"]));
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 31>", reply[0]["key 1"].inspect());
|
||||
assert.strictEqual("<Buffer 76 61 6c 20 32>", reply[0]["key 2"].inspect());
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1']));
|
||||
assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2']));
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 31>', reply[0]['key 1'].inspect());
|
||||
assert.strictEqual('<Buffer 76 61 6c 20 32>', reply[0]['key 2'].inspect());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
@@ -240,8 +240,8 @@ describe("return_buffers", function () {
|
||||
describe('publish/subscribe', function (done) {
|
||||
var pub;
|
||||
var sub;
|
||||
var channel = "test channel";
|
||||
var message = new Buffer("test message");
|
||||
var channel = 'test channel';
|
||||
var message = new Buffer('test message');
|
||||
|
||||
var args = config.configureClient(parser, ip, {
|
||||
return_buffers: true
|
||||
@@ -253,7 +253,7 @@ describe("return_buffers", function () {
|
||||
|
||||
pub = redis.createClient.apply(redis.createClient, basicArgs);
|
||||
sub = redis.createClient.apply(redis.createClient, args);
|
||||
pub.once("connect", function () {
|
||||
pub.once('connect', function () {
|
||||
pub.flushdb(function () {
|
||||
pubConnected = true;
|
||||
if (subConnected) {
|
||||
@@ -261,7 +261,7 @@ describe("return_buffers", function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
sub.once("connect", function () {
|
||||
sub.once('connect', function () {
|
||||
subConnected = true;
|
||||
if (pubConnected) {
|
||||
done();
|
||||
@@ -270,13 +270,13 @@ describe("return_buffers", function () {
|
||||
});
|
||||
|
||||
it('receives buffer messages', function (done) {
|
||||
sub.on("subscribe", function (chnl, count) {
|
||||
sub.on('subscribe', function (chnl, count) {
|
||||
pub.publish(channel, message);
|
||||
});
|
||||
|
||||
sub.on("message", function (chnl, msg) {
|
||||
sub.on('message', function (chnl, msg) {
|
||||
assert.strictEqual(true, Buffer.isBuffer(msg));
|
||||
assert.strictEqual("<Buffer 74 65 73 74 20 6d 65 73 73 61 67 65>", msg.inspect());
|
||||
assert.strictEqual('<Buffer 74 65 73 74 20 6d 65 73 73 61 67 65>', msg.inspect());
|
||||
return done();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user