docs(assert): improve assertObjectMatch docs (#5296)

This commit is contained in:
Yoshiya Hinosawa 2024-07-04 18:59:18 +09:00 committed by GitHub
parent ae956512eb
commit ee4600667f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,7 @@
import { assertEquals } from "./equals.ts";
/**
* Make an assertion that `actual` object is a subset of `expected` object,
* Make an assertion that `expected` object is a subset of `actual` object,
* deeply. If not, then throw.
*
* @example Usage
@ -14,6 +14,14 @@ import { assertEquals } from "./equals.ts";
* assertObjectMatch({ foo: "bar" }, { foo: "baz" }); // Throws
* ```
*
* @example Usage with nested objects
* ```ts no-eval
* import { assertObjectMatch } from "@std/assert";
*
* assertObjectMatch({ foo: { bar: 3, baz: 4 } }, { foo: { bar: 3 } }); // Doesn't throw
* assertObjectMatch({ foo: { bar: 3 } }, { foo: { bar: 3, baz: 4 } }); // Throws
* ```
*
* @param actual The actual value to be matched.
* @param expected The expected value to match.
* @param msg The optional message to display if the assertion fails.