forked from denoland/std
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(expect): support
expect.objectContaining
(denoland#6065)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
- Loading branch information
Showing
4 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { Buffer } from "node:buffer"; | ||
import { Buffer as DenoBuffer } from "@std/io/buffer"; | ||
import { expect } from "./expect.ts"; | ||
|
||
Deno.test("expect.objectContaining()", () => { | ||
expect({ bar: "baz" }).toEqual(expect.objectContaining({ bar: "baz" })); | ||
expect({ foo: undefined }).toEqual( | ||
expect.objectContaining({ foo: undefined }), | ||
); | ||
expect({ bar: "baz" }).not.toEqual(expect.objectContaining({ foo: "bar" })); | ||
}); | ||
|
||
Deno.test("expect.objectContaining() with nested objects", () => { | ||
expect({ foo: { bar: "baz" } }).toEqual( | ||
expect.objectContaining({ foo: { bar: "baz" } }), | ||
); | ||
expect({ foo: { bar: "baz" } }).not.toEqual( | ||
expect.objectContaining({ foo: { bar: "bar" } }), | ||
); | ||
}); | ||
|
||
Deno.test("expect.objectContaining() with symbols", () => { | ||
const foo = Symbol("foo"); | ||
expect({ [foo]: { bar: "baz" } }).toEqual( | ||
expect.objectContaining({ [foo]: { bar: "baz" } }), | ||
); | ||
}); | ||
|
||
Deno.test("expect.objectContaining() with nested arrays", () => { | ||
expect({ foo: ["bar", "baz"] }).toEqual( | ||
expect.objectContaining({ foo: ["bar", "baz"] }), | ||
); | ||
expect({ foo: ["bar", "baz"] }).not.toEqual( | ||
expect.objectContaining({ foo: ["bar", "bar"] }), | ||
); | ||
}); | ||
|
||
Deno.test("expect.objectContaining() with Node Buffer", () => { | ||
expect({ foo: Buffer.from("foo") }).toEqual( | ||
expect.objectContaining({ foo: Buffer.from("foo") }), | ||
); | ||
}); | ||
|
||
Deno.test("expect.objectContaining() with Deno Buffer", () => { | ||
expect({ foo: new DenoBuffer([1, 2, 3]) }).toEqual( | ||
expect.objectContaining({ foo: new DenoBuffer([1, 2, 3]) }), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters