2024-04-24 08:02:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
refactor(assert,async,bytes,cli,collections,crypto,csv,data-structures,datetime,dotenv,encoding,expect,fmt,front-matter,fs,html,http,ini,internal,io,json,jsonc,log,media-types,msgpack,net,path,semver,streams,testing,text,toml,ulid,url,uuid,webgpu,yaml): import from `@std/assert` (#5199)
* refactor: import from `@std/assert`
* update
2024-06-30 08:30:10 +00:00
|
|
|
import { assertEquals } from "@std/assert";
|
2024-09-27 01:57:14 +00:00
|
|
|
import { assertSpyCall, spy } from "@std/testing/mock";
|
|
|
|
import { red } from "@std/fmt/colors";
|
2024-04-24 08:02:32 +00:00
|
|
|
import { error } from "./error.ts";
|
|
|
|
|
|
|
|
Deno.test("error()", () => {
|
2024-09-27 01:57:14 +00:00
|
|
|
using consoleInfoSpy = spy(console, "log");
|
2024-04-24 08:02:32 +00:00
|
|
|
const errorData: undefined = error(undefined, 1, 2, 3);
|
|
|
|
const errorResolver: bigint | undefined = error(() => 5n);
|
|
|
|
assertEquals(errorData, undefined);
|
|
|
|
assertEquals(errorResolver, 5n);
|
2024-09-27 01:57:14 +00:00
|
|
|
assertSpyCall(consoleInfoSpy, 0, {
|
|
|
|
args: [red("ERROR undefined")],
|
|
|
|
});
|
|
|
|
assertSpyCall(consoleInfoSpy, 1, {
|
|
|
|
args: [red("ERROR 5")],
|
|
|
|
});
|
2024-04-24 08:02:32 +00:00
|
|
|
});
|