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