scroll/src/deno/test_base.ts

41 lines
907 B
JavaScript
Raw Normal View History

2023-11-03 11:59:58 -04:00
import { ITestBase } from '../common/mod.ts';
2023-11-16 16:00:03 -05:00
import { stdAssert } from './deps.ts';
const {
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,
2023-11-16 16:00:03 -05:00
} = stdAssert;
2023-11-03 11:59:58 -04:00
export function testSuite(testObj: any) {
Object.keys(testObj).forEach((group) => {
const groupObj = testObj[group];
Object.keys(groupObj).forEach((testName) => {
Deno.test(testName, groupObj[testName]);
});
});
}
2023-11-03 11:59:58 -04:00
const DenoTestBase: ITestBase = {
assertEquals,
assertExists,
assertInstanceOf,
assertNotEquals,
assertStrictEquals,
assertTrue: function (actual: boolean): void {
2023-11-03 11:59:58 -04:00
if (actual !== true) {
throw new AssertionError(`actual: "${actual}" expected to be true"`);
}
},
2023-11-03 11:59:58 -04:00
assertFalse(actual: boolean): void {
if (actual !== false) {
throw new AssertionError(`actual: "${actual}" expected to be false"`);
}
},
testSuite,
};
2023-11-03 11:59:58 -04:00
export default DenoTestBase;