forked from denoland/std
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnot_instance_of_test.ts
42 lines (37 loc) · 1.04 KB
/
not_instance_of_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
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { AssertionError, assertNotInstanceOf, assertThrows } from "./mod.ts";
Deno.test({
name: "assertNotInstanceOf()",
fn() {
assertNotInstanceOf("not a number", Number);
assertNotInstanceOf(42, String);
assertNotInstanceOf(new URL("http://example.com"), Boolean);
},
});
Deno.test({
name: "assertNotInstanceOf() accepts abstract class",
fn() {
abstract class AbstractClass {}
assertNotInstanceOf(AbstractClass, AbstractClass);
},
});
Deno.test({
name: "assertNotInstanceOf() throws",
fn() {
assertThrows(
() => assertNotInstanceOf(new Date(), Date),
AssertionError,
'Expected object to not be an instance of "function".',
);
},
});
Deno.test({
name: "assertNotInstanceOf() throws with custom message",
fn() {
assertThrows(
() => assertNotInstanceOf(new Date(), Date, "CUSTOM MESSAGE"),
AssertionError,
'Expected object to not be an instance of "function": CUSTOM MESSAGE',
);
},
});