scroll/src/deno/test_base.ts

46 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-11-29 16:09:58 -05:00
import { ITestBase } from '../common/types.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"`);
}
},
2023-11-30 16:14:52 -05:00
assertNull(actual: boolean): void {
if (actual !== null) {
throw new AssertionError(`actual: "${actual}" expected to be null"`);
}
},
testSuite,
};
2023-11-03 11:59:58 -04:00
export default DenoTestBase;