scroll/src/bun/test_base.ts

43 lines
1015 B
JavaScript

/**
* Adapt the bun test interface to the shared testing interface
*/
import { expect, test as btest } from 'bun:test';
import { ITestBase } from '../common/mod.ts';
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);
}
assertStrictEquals(actual: unknown, expected: unknown): void {
return expect(actual).toBe(expected);
}
}
const testBase = new TestBase();
export default testBase;