mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { expect } from "./expect.ts";
|
|
import { AssertionError, assertThrows } from "@std/assert";
|
|
|
|
Deno.test("expect().toMatchObject()", () => {
|
|
const house0 = {
|
|
bath: true,
|
|
bedrooms: 4,
|
|
kitchen: {
|
|
amenities: ["oven", "stove", "washer"],
|
|
area: 20,
|
|
wallColor: "white",
|
|
},
|
|
};
|
|
const house1 = {
|
|
bath: true,
|
|
bedrooms: 4,
|
|
kitchen: {
|
|
amenities: ["oven", "stove"],
|
|
area: 20,
|
|
wallColor: "white",
|
|
},
|
|
};
|
|
const desiredHouse = {
|
|
bath: true,
|
|
kitchen: {
|
|
amenities: ["oven", "stove", "washer"],
|
|
wallColor: "white",
|
|
},
|
|
};
|
|
|
|
expect(house0).toMatchObject(desiredHouse);
|
|
expect([house0]).toMatchObject([desiredHouse]);
|
|
|
|
expect(house1).not.toMatchObject(desiredHouse);
|
|
expect([house1]).not.toMatchObject([desiredHouse]);
|
|
|
|
assertThrows(() => {
|
|
expect(house1).toMatchObject(desiredHouse);
|
|
}, AssertionError);
|
|
assertThrows(() => {
|
|
expect([house1]).toMatchObject([desiredHouse]);
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
expect(house0).not.toMatchObject(desiredHouse);
|
|
}, AssertionError);
|
|
assertThrows(() => {
|
|
expect([house0]).not.toMatchObject([desiredHouse]);
|
|
}, AssertionError);
|
|
});
|