38 lines
900 B
JavaScript
38 lines
900 B
JavaScript
|
/**
|
||
|
* Adapt the bun test interface to the shared testing interface
|
||
|
*/
|
||
|
import {test as btest, expect } from 'bun:test';
|
||
|
import {ITestBase} from "../common/mod";
|
||
|
|
||
|
class TestBase implements ITestBase {
|
||
|
test(name: string, fn: () => void) {
|
||
|
return btest(name, fn);
|
||
|
}
|
||
|
|
||
|
assertEquals(actual: unknown, expected: unknown): void {
|
||
|
return expect(actual).toEqual(expected);
|
||
|
}
|
||
|
|
||
|
assertExists(actual: unknown): void {
|
||
|
return expect(actual).toBeDefined();
|
||
|
}
|
||
|
|
||
|
assertInstanceOf(actual: unknown, expectedType: any): void {
|
||
|
return expect(actual).toBeInstanceOf(expectedType);
|
||
|
}
|
||
|
|
||
|
assertNotEquals(actual: unknown, expected: unknown): void {
|
||
|
return expect(actual).not.toBe(expected);
|
||
|
}
|
||
|
|
||
|
assertFalse(actual: boolean): void {
|
||
|
return expect(actual).toBe(false);
|
||
|
}
|
||
|
|
||
|
assertTrue(actual: boolean): void {
|
||
|
return expect(actual).toBe(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const testBase = new TestBase();
|
||
|
export default testBase;
|