-
Notifications
You must be signed in to change notification settings - Fork 576
/
_to_be_truthy_test.ts
38 lines (33 loc) · 989 Bytes
/
_to_be_truthy_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
// 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().toBeTruthy()", () => {
expect(1).toBeTruthy();
expect("hello").toBeTruthy();
expect({}).toBeTruthy();
expect(0).not.toBeTruthy();
expect("").not.toBeTruthy();
expect(null).not.toBeTruthy();
expect(undefined).not.toBeTruthy();
assertThrows(() => {
expect(0).toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect("").toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect(null).toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect(undefined).toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect(1).not.toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect("hello").not.toBeTruthy();
}, AssertionError);
assertThrows(() => {
expect({}).not.toBeTruthy();
}, AssertionError);
});