2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-05-07 00:08:16 +00:00
|
|
|
import { AssertionError, assertNotInstanceOf, assertThrows } from "./mod.ts";
|
2023-07-13 07:04:30 +00:00
|
|
|
|
|
|
|
Deno.test({
|
2024-05-07 00:08:16 +00:00
|
|
|
name: "assertNotInstanceOf()",
|
2023-07-13 07:04:30 +00:00
|
|
|
fn() {
|
|
|
|
assertNotInstanceOf("not a number", Number);
|
|
|
|
assertNotInstanceOf(42, String);
|
|
|
|
assertNotInstanceOf(new URL("http://example.com"), Boolean);
|
|
|
|
},
|
|
|
|
});
|
2024-05-07 00:08:16 +00:00
|
|
|
|
2024-09-17 06:28:22 +00:00
|
|
|
Deno.test({
|
|
|
|
name: "assertNotInstanceOf() accepts abstract class",
|
|
|
|
fn() {
|
|
|
|
abstract class AbstractClass {}
|
|
|
|
|
|
|
|
assertNotInstanceOf(AbstractClass, AbstractClass);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-05-07 00:08:16 +00:00
|
|
|
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',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|