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

Add some more notes and tests

This commit is contained in:
Ruben Bridgewater
2015-10-12 17:21:58 +02:00
parent 352f8a5be3
commit 06f57fd1d9
3 changed files with 71 additions and 5 deletions

View File

@@ -63,6 +63,21 @@ describe("The 'batch' method", function () {
client.end();
});
it("returns an empty array", function (done) {
var batch = client.batch();
batch.exec(function (err, res) {
assert.strictEqual(err, null);
assert.strictEqual(res.length, 0);
done();
});
});
it("returns an empty array if promisified", function () {
return client.batch().execAsync().then(function(res) {
assert.strictEqual(res.length, 0);
});
});
it("returns an empty result array", function (done) {
var batch = client.batch();
var async = true;

View File

@@ -285,6 +285,51 @@ describe("publish/subscribe", function () {
});
});
// TODO: Fix pub sub
// And there's more than just those two issues
describe.skip('FIXME: broken pub sub', function () {
it("should not publish a message without any publish command", function (done) {
pub.set('foo', 'message');
pub.set('bar', 'hello');
pub.mget('foo', 'bar');
pub.subscribe('channel');
pub.on('message', function (msg) {
done(new Error('This message should not have been published: ' + msg));
});
setTimeout(done, 500);
});
it("should not publish a message multiple times per command", function (done) {
var published = {};
function subscribe(message) {
sub.on('subscribe', function () {
pub.publish('/foo', message);
});
sub.on('message', function (channel, message) {
if (published[message]) {
done(new Error('Message published more than once.'));
}
published[message] = true;
});
sub.on('unsubscribe', function (channel, count) {
assert.strictEqual(count, 0);
});
sub.subscribe('/foo');
}
subscribe('hello');
setTimeout(function () {
sub.unsubscribe();
setTimeout(function () {
subscribe('world');
}, 400);
}, 400);
});
});
afterEach(function () {
sub.end();
pub.end();