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
|
|
|
|
2023-11-16 20:57:21 -05: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
|
|
|
|
2023-11-16 20:57:21 -05: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-16 20:57:21 -05:00
|
|
|
},
|
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-16 20:57:21 -05:00
|
|
|
},
|
|
|
|
testSuite,
|
|
|
|
};
|
2023-11-03 11:59:58 -04:00
|
|
|
|
2023-11-16 20:57:21 -05:00
|
|
|
export default DenoTestBase;
|