2023-11-03 11:59:58 -04:00
|
|
|
/**
|
|
|
|
* Adapt the bun test interface to the shared testing interface
|
|
|
|
*/
|
2023-11-16 20:57:21 -05:00
|
|
|
import { describe, expect, 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 = {
|
|
|
|
assertEquals: (actual: unknown, expected: unknown) =>
|
|
|
|
expect(actual).toEqual(expected),
|
|
|
|
assertExists: (actual: unknown) => expect(actual).toBeDefined(),
|
|
|
|
assertFalse: (actual: boolean) => expect(actual).toBe(false),
|
|
|
|
assertInstanceOf: (actual: unknown, expectedType: any) =>
|
|
|
|
expect(actual).toBeInstanceOf(expectedType),
|
|
|
|
assertNotEquals: (actual: unknown, expected: unknown) =>
|
|
|
|
expect(actual).not.toBe(expected),
|
2023-11-30 16:14:52 -05:00
|
|
|
assertNull: (actual: unknown) => expect(actual).toBeNull(),
|
2023-11-16 20:57:21 -05:00
|
|
|
assertStrictEquals: (actual: unknown, expected: unknown) =>
|
|
|
|
expect(actual).toBe(expected),
|
|
|
|
assertTrue: (actual: boolean) => expect(actual).toBe(true),
|
|
|
|
testSuite,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BunTestBase;
|