-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement deep keys assertions for Maps/Sets #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Implements Chai-compatible “deep keys” assertions so Maps/Sets with object keys can be asserted via deep equality, and wires this into both the core expect/assert APIs and the Chai shim.
Changes:
- Adds
anyDeepKeysFunc/allDeepKeysFuncand integrates.deep.keysoperation chaining. - Exposes new core assert APIs (
hasAnyDeepKeys,hasAllDeepKeys, and negations) and updates type interfaces. - Adds/updates tests and documentation for deep-keys support (core + chai shim).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| shim/chai/test/src/chaiAssert.test.ts | Enables deep-keys-related Chai shim tests for Maps/Sets. |
| shim/chai/src/assert/chaiAssert.ts | Adds Chai shim assert-method mappings for deep keys. |
| shim/chai/README.md | Documents deep keys support in the Chai shim. |
| core/test/src/assert/assert.deepKeys.test.ts | Adds core tests covering deep-keys behavior and edge cases. |
| core/src/assert/ops/keysOp.ts | Adds deep key filter operations and deepKeysOp selector. |
| core/src/assert/ops/deepOp.ts | Exposes .deep.keys chaining from the deep operation. |
| core/src/assert/ops/allOp.ts | Adds .any.deep.keys / .all.deep.keys chaining support. |
| core/src/assert/interface/ops/IDeepOp.ts | Extends IDeepOp to include keys operations. |
| core/src/assert/interface/ops/IAnyOp.ts | Adds deep key operations to the any op typing/docs. |
| core/src/assert/interface/ops/IAllOp.ts | Adds deep key operations to the all op typing/docs. |
| core/src/assert/interface/IAssertClass.ts | Adds public assert method typings/docs for deep keys and negations. |
| core/src/assert/funcs/keysFunc.ts | Implements deep key matching and improved key formatting for messages. |
| core/src/assert/assertClass.ts | Registers new deep-keys assert functions and aliases. |
| core/README.md | Documents core deep-keys support at a high level. |
| .github/copilot-instructions.md | Adds contributor guidance for selecting @since versions for new features. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Add deep equality key comparison for Maps and Sets with object keys. Implements anyDeepKeysFunc, allDeepKeysFunc, and six assert methods (hasAnyDeepKeys, hasAllDeepKeys, and their negations). Addresses Chai v5.x compatibility for deep keys operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
| map.set({ greeting: "hello", subject: "friend" }, "value1"); | ||
| map.set({ message: "darkness", type: "familiar" }, "value2"); | ||
|
|
||
| expect(map).to.have.any.deep.keys({ greeting: "hello", subject: "friend" }); | ||
| expect(map).to.have.any.deep.keys({ message: "darkness", type: "familiar" }); | ||
| expect(map).to.have.any.deep.keys([{ greeting: "hello", subject: "friend" }, { echo: "calling" }]); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new test file includes multiple blank lines that contain trailing spaces (e.g., after the map.set(...) lines). With no-trailing-spaces enabled, this will generate lint warnings; please remove the trailing whitespace (ideally across the whole file).
| // Deep keys operations | ||
| hasAnyDeepKeys: { scopeFn: createExprAdapter("has.any.deep.keys"), nArgs: 2 }, | ||
| hasAllDeepKeys: { scopeFn: createExprAdapter("has.all.deep.keys"), nArgs: 2 }, | ||
| notHaveAnyDeepKeys: { scopeFn: createExprAdapter("not.has.any.deep.keys"), nArgs: 2 }, | ||
| doesNotHaveAnyDeepKeys: { alias: "notHaveAnyDeepKeys" }, | ||
| notHaveAllDeepKeys: { scopeFn: createExprAdapter("not.has.all.deep.keys"), nArgs: 2 }, | ||
| doesNotHaveAllDeepKeys: { alias: "notHaveAllDeepKeys" } |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New core assert API methods were added (hasAnyDeepKeys, hasAllDeepKeys, notHaveAnyDeepKeys/doesNotHaveAnyDeepKeys, notHaveAllDeepKeys/doesNotHaveAllDeepKeys), but there are no corresponding unit tests in core/test/src/assert/ covering these assert entry points. There is extensive coverage for other assert.* methods, so please add tests validating both passing and failing cases for these new methods (including Map/Set object-key scenarios and the alias methods).
Add deep equality key comparison for Maps and Sets with object keys. Implements anyDeepKeysFunc, allDeepKeysFunc, and six assert methods (hasAnyDeepKeys, hasAllDeepKeys, and their negations).
Addresses Chai v5.x compatibility for deep keys operations.