You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
Use a .create_stream function, so other libraries can mock the stream if wanted
Reference https://github.com/hdachev/fakeredis/pull/34
This commit is contained in:
@@ -320,9 +320,22 @@ describe("connection tests", function () {
|
||||
});
|
||||
});
|
||||
|
||||
it("works with missing options object for new redis instances", function () {
|
||||
// This is needed for libraries that have their own createClient function like fakeredis
|
||||
client = new redis.RedisClient({ on: function () {}});
|
||||
it("fake the stream to mock redis", function () {
|
||||
// This is needed for libraries that want to mock the stream like fakeredis
|
||||
var temp = redis.RedisClient.prototype.create_stream;
|
||||
var create_stream_string = String(temp);
|
||||
redis.RedisClient.prototype.create_stream = function () {
|
||||
this.connected = true;
|
||||
this.ready = true;
|
||||
};
|
||||
client = new redis.RedisClient();
|
||||
assert.strictEqual(client.stream, undefined);
|
||||
assert.strictEqual(client.ready, true);
|
||||
assert.strictEqual(client.connected, true);
|
||||
client.end = function () {};
|
||||
assert(create_stream_string !== String(redis.RedisClient.prototype.create_stream));
|
||||
redis.RedisClient.prototype.create_stream = temp;
|
||||
assert(create_stream_string === String(redis.RedisClient.prototype.create_stream));
|
||||
});
|
||||
|
||||
it("throws on strange connection info", function () {
|
||||
|
Reference in New Issue
Block a user