Open
Description
First off thank you for the good work on this library. Found a couple missing features:
ioredis has a status
property to check the connection status of the client (ready
, wait
, end
)
ioredis emits end
on disconnect.
quick fix for anyone looking for this until it's resolved:
class IoRedisMock extends RedisMock {
constructor(opts) {
super(opts);
this.lazyConnnect = opts && opts.lazyConnnect;
}
get status() {
return this.connected ? 'ready' : this.lazyConnnect ? 'wait' : 'end';
}
disconnect() {
process.nextTick(() => this.emit('end'));
super.disconnect();
this.connected = false;
}
}
IoRedisMock.Cluster = class IoRedisClusterMock extends IoRedisMock {
constructor(nodesOptions) {
super();
this.nodes = [];
nodesOptions.forEach(options => this.nodes.push(new IoRedisMock(options)));
}
};
Metadata
Assignees
Labels
No labels