Skip to content

Commit

Permalink
test: add zscan's test
Browse files Browse the repository at this point in the history
Signed-off-by: jhpung <[email protected]>
  • Loading branch information
jhpung committed Oct 18, 2024
1 parent 0fa2e41 commit 489345f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/unit/commander.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as sinon from "sinon";
import { expect } from "chai";
import Commander from "../../lib/utils/Commander";
import Command from "../../lib/Command";

describe("Commander", () => {
describe("#getBuiltinCommands()", () => {
Expand Down Expand Up @@ -63,4 +64,21 @@ describe("Commander", () => {

Commander.prototype.sendCommand.restore();
});

describe("#zscan", () => {
it("should pass noscores option", async (done) => {
const args: any[] = ["key", "0", "MATCH", "pattern", "COUNT", "10", "noscores"];
sinon.stub(Commander.prototype, "sendCommand").callsFake((command) => {
if(command.args.every((arg, index) => arg === args[index])) {
return done();
}
console.error(command.args);
return done(new Error(`args should be ${args.join(", ")}`));
});
const c = new Commander();

await c.zscan(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
(Commander.prototype.sendCommand as any).restore();
});
});
});

0 comments on commit 489345f

Please sign in to comment.