it("[[Call]] calls the constraint if the match succeeds", () => {
const constraint = spy((_) => true);
- const matcher = new Matcher(".*", undefined, constraint);
- matcher.exec({
+ const matcher = new Matcher("(.).*", undefined, constraint);
+ const result = matcher.exec({
toString() {
return "etaoin";
},
});
assertSpyCalls(constraint, 1);
assertSpyCall(constraint, 0, {
- args: ["etaoin", matcher],
+ args: ["etaoin", result, matcher],
self: undefined,
});
});
it("[[Call]] calls the constraint if the match succeeds", () => {
const constraint = spy((_) => true);
- const matcher = new Matcher(".*", undefined, constraint);
+ const matcher = new Matcher("(.).*", undefined, constraint);
matcher("etaoin");
assertSpyCalls(constraint, 1);
- assertSpyCall(constraint, 0, {
- args: ["etaoin", matcher],
- self: undefined,
- });
+ assertEquals(constraint.calls[0].args[0], "etaoin");
+ assertEquals([...constraint.calls[0].args[1]], ["etaoin", "e"]);
+ assertEquals(constraint.calls[0].args[2], matcher);
+ assertEquals(constraint.calls[0].self, undefined);
});
it("[[Call]] does not call the constraint if the match fails", () => {