1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

chore: use standard

This commit is contained in:
Ruben Bridgewater
2017-05-06 07:06:52 +02:00
parent 5d29f541e9
commit f1a7bcd735
106 changed files with 10706 additions and 10978 deletions

View File

@@ -1,95 +1,93 @@
'use strict';
'use strict'
var assert = require('assert');
var config = require('../lib/config');
var helper = require('../helper');
var redis = config.redis;
var uuid = require('uuid');
var assert = require('assert')
var config = require('../lib/config')
var helper = require('../helper')
var redis = config.redis
var uuid = require('uuid')
describe("The 'get' method", function () {
describe('The \'get\' method', function () {
helper.allTests(function (ip, args) {
describe('using ' + ip, function () {
var key, value
helper.allTests(function (ip, args) {
beforeEach(function () {
key = uuid.v4()
value = uuid.v4()
})
describe('using ' + ip, function () {
var key, value;
describe('when not connected', function () {
var client
beforeEach(function () {
key = uuid.v4();
value = uuid.v4();
});
beforeEach(function (done) {
client = redis.createClient.apply(null, args)
client.once('ready', function () {
client.quit()
})
client.on('end', done)
})
describe('when not connected', function () {
var client;
it('reports an error', function (done) {
client.get(key, function (err, res) {
assert(err.message.match(/The connection is already closed/))
done()
})
})
beforeEach(function (done) {
client = redis.createClient.apply(null, args);
client.once('ready', function () {
client.quit();
});
client.on('end', done);
});
it('reports an error promisified', function () {
return client.getAsync(key).then(assert, function (err) {
assert(err.message.match(/The connection is already closed/))
})
})
})
it('reports an error', function (done) {
client.get(key, function (err, res) {
assert(err.message.match(/The connection is already closed/));
done();
});
});
describe('when connected', function () {
var client
it('reports an error promisified', function () {
return client.getAsync(key).then(assert, function (err) {
assert(err.message.match(/The connection is already closed/));
});
});
});
beforeEach(function (done) {
client = redis.createClient.apply(null, args)
client.once('ready', function () {
done()
})
})
describe('when connected', function () {
var client;
afterEach(function () {
client.end(true)
})
beforeEach(function (done) {
client = redis.createClient.apply(null, args);
client.once('ready', function () {
done();
});
});
describe('when the key exists in Redis', function () {
beforeEach(function (done) {
client.set(key, value, function (err, res) {
helper.isNotError()(err, res)
done()
})
})
afterEach(function () {
client.end(true);
});
it('gets the value correctly', function (done) {
client.get(key, function (err, res) {
helper.isString(value)(err, res)
done(err)
})
})
describe('when the key exists in Redis', function () {
beforeEach(function (done) {
client.set(key, value, function (err, res) {
helper.isNotError()(err, res);
done();
});
});
it('should not throw on a get without callback (even if it\'s not useful)', function (done) {
client.get(key)
client.on('error', function (err) {
throw err
})
setTimeout(done, 25)
})
})
it('gets the value correctly', function (done) {
client.get(key, function (err, res) {
helper.isString(value)(err, res);
done(err);
});
});
it("should not throw on a get without callback (even if it's not useful)", function (done) {
client.get(key);
client.on('error', function (err) {
throw err;
});
setTimeout(done, 25);
});
});
describe('when the key does not exist in Redis', function () {
it('gets a null value', function (done) {
client.get(key, function (err, res) {
helper.isNull()(err, res);
done(err);
});
});
});
});
});
});
});
describe('when the key does not exist in Redis', function () {
it('gets a null value', function (done) {
client.get(key, function (err, res) {
helper.isNull()(err, res)
done(err)
})
})
})
})
})
})
})