scroll/src/deno/test_base.ts

41 lines
907 B
JavaScript

import { ITestBase } from '../common/mod.ts';
import { stdAssert } from './deps.ts';
const {
assertEquals,
assertExists,
assertInstanceOf,
AssertionError,
assertNotEquals,
assertStrictEquals,
} = stdAssert;
export function testSuite(testObj: any) {
Object.keys(testObj).forEach((group) => {
const groupObj = testObj[group];
Object.keys(groupObj).forEach((testName) => {
Deno.test(testName, groupObj[testName]);
});
});
}
const DenoTestBase: ITestBase = {
assertEquals,
assertExists,
assertInstanceOf,
assertNotEquals,
assertStrictEquals,
assertTrue: function (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"`);
}
},
testSuite,
};
export default DenoTestBase;