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
|
|
|
|
|
|
|
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().toBe()", () => {
|
|
|
|
const obj = {};
|
|
|
|
expect(1).toBe(1);
|
|
|
|
expect("hello").toBe("hello");
|
|
|
|
expect(obj).toBe(obj);
|
|
|
|
|
|
|
|
expect(1).not.toBe(2);
|
|
|
|
expect("hello").not.toBe("world");
|
|
|
|
expect(obj).not.toBe({});
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(1).toBe(2);
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect("hello").toBe("world");
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(obj).toBe({});
|
|
|
|
}, AssertionError);
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(1).not.toBe(1);
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect("hello").not.toBe("hello");
|
|
|
|
}, AssertionError);
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(obj).not.toBe(obj);
|
|
|
|
}, AssertionError);
|
2024-01-29 08:55:56 +00:00
|
|
|
|
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
expect(new A()).not.toBe(new B());
|
|
|
|
assertThrows(() => {
|
|
|
|
expect(new A()).toBe(new B());
|
|
|
|
}, AssertionError);
|
2023-11-21 14:52:38 +00:00
|
|
|
});
|