Skip to content

fix(testing): Function signature of assertObjectEquals() does not accept interfaces #741 #763

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

Merged
merged 5 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion testing/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ export function assertNotMatch(
* If not, then throw.
*/
export function assertObjectMatch(
actual: Record<PropertyKey, unknown>,
// deno-lint-ignore no-explicit-any
actual: Record<PropertyKey, any>,
expected: Record<PropertyKey, unknown>,
): void {
type loose = Record<PropertyKey, unknown>;
Expand Down
8 changes: 8 additions & 0 deletions testing/asserts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ Deno.test("testingAssertObjectMatching", function (): void {
const e = { foo: true } as { [key: string]: unknown };
e.bar = e;
const f = { [sym]: true, bar: false };
interface r {
foo: boolean;
bar: boolean;
}
const g: r = { foo: true, bar: false };

// Simple subset
assertObjectMatch(a, {
foo: true,
Expand Down Expand Up @@ -349,6 +355,8 @@ Deno.test("testingAssertObjectMatching", function (): void {
},
},
});
// Subset with interface
assertObjectMatch(g, { bar: false });
// Subset with same symbol
assertObjectMatch(f, {
[sym]: true,
Expand Down