std/log/error_test.ts
Asher Gomez 2774a070d6
fix(log): ensure consistent behavior with @std/log (#5974)
* fix(log): ensure consistent behavior with `@std/log`

* update

* fixes
2024-09-27 10:57:14 +09:00

20 lines
672 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "@std/assert";
import { assertSpyCall, spy } from "@std/testing/mock";
import { red } from "@std/fmt/colors";
import { error } from "./error.ts";
Deno.test("error()", () => {
using consoleInfoSpy = spy(console, "log");
const errorData: undefined = error(undefined, 1, 2, 3);
const errorResolver: bigint | undefined = error(() => 5n);
assertEquals(errorData, undefined);
assertEquals(errorResolver, 5n);
assertSpyCall(consoleInfoSpy, 0, {
args: [red("ERROR undefined")],
});
assertSpyCall(consoleInfoSpy, 1, {
args: [red("ERROR 5")],
});
});