2023-11-03 11:59:58 -04:00
|
|
|
/**
|
|
|
|
* Adapt the bun test interface to the shared testing interface
|
|
|
|
*/
|
2024-07-09 16:12:28 -04:00
|
|
|
import { deepStrictEqual, notStrictEqual, strictEqual } from 'node:assert';
|
|
|
|
import { describe, test } from 'bun:test';
|
2023-11-29 16:09:58 -05:00
|
|
|
import { ITestBase } from '../common/types.ts';
|
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) => {
|
|
|
|
describe(group, () => {
|
|
|
|
const groupObj = testObj[group];
|
|
|
|
Object.keys(groupObj).forEach((testName) => {
|
|
|
|
test(testName, groupObj[testName]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-11-03 11:59:58 -04:00
|
|
|
}
|
|
|
|
|
2023-11-16 20:57:21 -05:00
|
|
|
const BunTestBase: ITestBase = {
|
2024-07-09 16:12:28 -04:00
|
|
|
assertEquivalent: (actual: unknown, expected: unknown) =>
|
|
|
|
deepStrictEqual(actual, expected),
|
|
|
|
assertExists: (actual: unknown) => notStrictEqual(actual, undefined),
|
|
|
|
assertFalse: (actual: boolean) => strictEqual(actual, false),
|
2023-11-16 20:57:21 -05:00
|
|
|
assertInstanceOf: (actual: unknown, expectedType: any) =>
|
2024-07-09 16:12:28 -04:00
|
|
|
strictEqual(actual instanceof expectedType, true),
|
2023-11-16 20:57:21 -05:00
|
|
|
assertNotEquals: (actual: unknown, expected: unknown) =>
|
2024-07-09 16:12:28 -04:00
|
|
|
notStrictEqual(actual, expected),
|
|
|
|
assertEquals: (actual: unknown, expected: unknown) =>
|
|
|
|
strictEqual(actual, expected),
|
|
|
|
assertTrue: (actual: boolean) => strictEqual(actual, true),
|
2023-11-16 20:57:21 -05:00
|
|
|
testSuite,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BunTestBase;
|