Initial Commit

This commit is contained in:
2025-08-16 14:17:46 -04:00
commit 651a21a035
49 changed files with 1347 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import type {Mock} from 'bun:test';
import {mock, describe, it, beforeEach, expect} from 'bun:test';
import {Disposable} from '../../src/disposables';
describe(`When using a Disposable`, () => {
describe(`Given a Disposable`, () => {
let mockFunction: Mock<any>;
let disposable: Disposable;
beforeEach(() => {
mockFunction = mock(() => {});
disposable = new Disposable(mockFunction);
});
describe(`Given the disposable is disposed`, () => {
beforeEach(() => {
disposable.dispose();
});
it(`executes the disposble`, () => {
expect(mockFunction).toHaveBeenCalled();
});
it(`marks the disposbale disposed`, () => {
expect(disposable.isDisposed).toBeTrue();
});
describe(`Given the disposable is repeatedly disposed`, () => {
beforeEach(() => {
for (let count = 0; count < 10; count++) {
disposable.dispose();
}
});
it(`disposes the disposable only once`, () => {
expect(mockFunction).toHaveBeenCalledTimes(1);
});
});
});
});
});