scroll/src/deno/test_base.ts

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-11-03 11:59:58 -04:00
import { ITestBase } from '../common/mod.ts';
import {
2023-11-02 13:06:48 -04:00
assertEquals,
2023-11-03 11:59:58 -04:00
assertExists,
assertInstanceOf,
AssertionError,
2023-11-02 13:06:48 -04:00
assertNotEquals,
assertStrictEquals,
} from 'https://deno.land/std/assert/mod.ts';
2023-11-03 11:59:58 -04:00
class TestBase implements ITestBase {
test(name: string, fn: () => void): void {
return Deno.test(name, fn);
}
assertEquals(actual: unknown, expected: unknown): void {
return assertEquals(actual, expected);
}
assertStrictEquals(actual: unknown, expected: unknown) {
return assertStrictEquals(actual, expected);
}
assertNotEquals(actual: unknown, expected: unknown): void {
return assertNotEquals(actual, expected);
}
assertExists(actual: unknown, msg?: string): void {
return assertExists(actual, msg);
}
assertInstanceOf(actual: unknown, expectedType: any): void {
return assertInstanceOf(actual, expectedType);
}
assertTrue(actual: boolean): void {
if (actual !== true) {
throw new AssertionError(`actual: "${actual}" expected to be true"`);
}
}
assertFalse(actual: boolean): void {
if (actual !== false) {
throw new AssertionError(`actual: "${actual}" expected to be false"`);
}
}
}
const testBase = new TestBase();
2023-11-03 11:59:58 -04:00
export default testBase;