deno.land / std@0.224.0 / expect / _to_match_object_test.ts

_to_match_object_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { expect } from "./expect.ts";import { AssertionError, assertThrows } from "../assert/mod.ts";
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);});
std

Version Info

Tagged at
3 weeks ago