Skip to content

Commit

Permalink
feat: going one level deeper for size assertions (supporting $gt, $gt…
Browse files Browse the repository at this point in the history
…e, etc.)
  • Loading branch information
Varun0157 committed May 11, 2024
1 parent 47137ec commit dc42f05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ function runObjectTests(
} else if (typeof receivedObject === "string" || Array.isArray(receivedObject)) {
receivedLen = receivedObject.length;
}
pass = receivedLen === expected;
if (typeof expected === "number") {
pass = receivedLen === expected;
} else {
try {
expected = JSON.parse(expected);
} catch (err: any) {
message = `$size val is not num or valid JSON`;
}
results.push(...runObjectTests(expected, receivedLen, spec));
continue;
}
} else if (op === "$exists") {
const exists = received != undefined;
pass = exists === expected;
Expand Down

0 comments on commit dc42f05

Please sign in to comment.