// main_test.ts
import { describe } from "https://deno.land/std@0.212.0/testing/bdd.ts";
import { stub } from "https://deno.land/std@0.212.0/testing/mock.ts";
import { assertRejects } from "https://deno.land/std@0.212.0/assert/mod.ts";
import { MainClass } from "./main.ts";
describe("unit test", () => {
const mainObj = new MainClass();
const barStub = stub(
mainObj,
"bar",
() => new Promise((_, reject) => reject(new Error())),
);
assertRejects(() => mainObj.mainFn(), "yeah, bar() rejects with Error");
barStub.restore();
});
// main_test.ts
import { describe } from "https://deno.land/std@0.212.0/testing/bdd.ts";
import { stub } from "https://deno.land/std@0.212.0/testing/mock.ts";
import { assertRejects } from "https://deno.land/std@0.212.0/assert/mod.ts";
import { MainClass } from "./main.ts";
describe("unit test", () => {
const mainObj = new MainClass();
const barStub = stub(
mainObj,
"bar",
() => new Promise((_, reject) => reject(new Error())),
);
assertRejects(() => mainObj.mainFn(), "yeah, bar() rejects with Error");
barStub.restore();
});