-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_test.ts
42 lines (40 loc) · 1.31 KB
/
error_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
assert,
assertEquals,
assertInstanceOf,
assertMatch,
} from "@std/assert";
import { BatchError } from "./error.ts";
Deno.test("BatchError", async (t) => {
await t.step(".constructor()", async (t) => {
await t.step("constructs an instance", () => {
const actual = new BatchError("foo", ["bar", 1, true]);
assertInstanceOf(actual, BatchError);
});
});
await t.step(".name getter", async (t) => {
await t.step("returns 'BatchError'", () => {
const actual = new BatchError("foo", ["bar", 1, true]);
assertEquals(actual.name, "BatchError");
});
});
await t.step(".message getter", async (t) => {
await t.step("returns an error message", () => {
const actual = new BatchError("foo", ["bar", 1, true]);
assertEquals(actual.message, "foo");
});
});
await t.step(".stack getter", async (t) => {
await t.step("returns an error stack trace", () => {
const actual = new BatchError("foo", ["bar", 1, true]);
assert(actual.stack);
assertMatch(actual.stack, /\bat .*error_test\.ts:\d+:\d+\n/);
});
});
await t.step(".results getter", async (t) => {
await t.step("returns a results array", () => {
const actual = new BatchError("foo", ["bar", 1, true]);
assertEquals(actual.results, ["bar", 1, true]);
});
});
});