mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
28 lines
735 B
TypeScript
28 lines
735 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
// deno-lint-ignore-file no-explicit-any
|
|
|
|
import { expect } from "./expect.ts";
|
|
import { AssertionError, assertThrows } from "@std/assert";
|
|
|
|
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);
|
|
});
|