2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-11-21 14:52:38 +00:00
|
|
|
// deno-lint-ignore-file no-explicit-any
|
|
|
|
|
|
|
|
import { expect } from "./expect.ts";
|
2024-04-29 02:57:30 +00:00
|
|
|
import { AssertionError, assertThrows } from "@std/assert";
|
2023-11-21 14:52:38 +00:00
|
|
|
|
|
|
|
Deno.test("expect().toBeDefined()", () => {
|
|
|
|
expect(1).toBeDefined();
|
|
|
|
expect("a").toBeDefined();
|
|
|
|
|
|
|
|
expect(undefined).not.toBeDefined();
|
|
|
|
expect(({} as any).foo).not.toBeDefined();
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(undefined).toBeDefined();
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(({} as any).foo).toBeDefined();
|
|
|
|
}, AssertionError);
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(1).not.toBeDefined();
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect("a").not.toBeDefined();
|
|
|
|
}, AssertionError);
|
|
|
|
});
|