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

_to_be_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
// 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().toBe()", () => { const obj = {}; expect(1).toBe(1); expect("hello").toBe("hello"); expect(obj).toBe(obj);
expect(1).not.toBe(2); expect("hello").not.toBe("world"); expect(obj).not.toBe({});
assertThrows(() => { expect(1).toBe(2); }, AssertionError); assertThrows(() => { expect("hello").toBe("world"); }, AssertionError); assertThrows(() => { expect(obj).toBe({}); }, AssertionError);
assertThrows(() => { expect(1).not.toBe(1); }, AssertionError); assertThrows(() => { expect("hello").not.toBe("hello"); }, AssertionError); assertThrows(() => { expect(obj).not.toBe(obj); }, AssertionError);
class A {} class B {} expect(new A()).not.toBe(new B()); assertThrows(() => { expect(new A()).toBe(new B()); }, AssertionError);});
std

Version Info

Tagged at
3 weeks ago