1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00

fix(std/testing) assertArrayContains should work with any array-like (#6402)

This commit is contained in:
Casper Beyer 2020-06-24 20:29:50 +08:00 committed by GitHub
parent 1d8fc39494
commit f318ab01a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -269,8 +269,8 @@ export function assertStringContains(
* If not then thrown.
*/
export function assertArrayContains(
actual: unknown[],
expected: unknown[],
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
msg?: string
): void {
const missing: unknown[] = [];

View file

@ -159,6 +159,10 @@ Deno.test("testingArrayContains", function (): void {
const fixtureObject = [{ deno: "luv" }, { deno: "Js" }];
assertArrayContains(fixture, ["deno"]);
assertArrayContains(fixtureObject, [{ deno: "luv" }]);
assertArrayContains(
Uint8Array.from([1, 2, 3, 4]),
Uint8Array.from([1, 2, 3])
);
assertThrows(
(): void => assertArrayContains(fixtureObject, [{ deno: "node" }]),
AssertionError,