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

Increase the coverage by adding tests and fix a failing ready check

This commit is contained in:
Ruben Bridgewater
2015-09-21 02:38:27 +02:00
parent 6975b0723d
commit 6958c1854b
5 changed files with 79 additions and 44 deletions

View File

@@ -70,6 +70,7 @@ describe("The 'set' method", function () {
it("reports an error", function (done) {
client.set(undefined, function (err, res) {
helper.isError()(err, null);
assert.equal(err.command, 'SET');
done();
});
});
@@ -90,29 +91,36 @@ describe("The 'set' method", function () {
});
describe("with undefined 'key' and missing 'value' parameter", function () {
it("does not emit an error", function (done) {
this.timeout(200);
client.once("error", function (err) {
done(err);
});
client.set();
setTimeout(function () {
done();
}, 100);
});
it("does emit an error", function (done) {
it("emits an error without callback", function (done) {
client.on('error', function (err) {
assert.equal(err.message, "ERR wrong number of arguments for 'set' command");
assert.equal(err.message, 'send_command: SET value must not be undefined or null');
assert.equal(err.command, 'SET');
done();
});
client.set('foo');
client.set(undefined);
});
});
it("emit an error with only the key set", function (done) {
client.on('error', function (err) {
assert.equal(err.message, "ERR wrong number of arguments for 'set' command");
done();
});
client.set('foo');
});
it("emit an error without any parameters", function (done) {
client.once("error", function (err) {
assert.equal(err.message, 'send_command: SET value must not be undefined or null');
assert.equal(err.command, 'SET');
done();
});
// This was not supported not to throw earlier and was added by the test refactoring
// https://github.com/NodeRedis/node_redis/commit/eaca486ab1aecd1329f7452ad2f2255b1263606f
client.set();
});
});
});
});