Initial Commit
This commit is contained in:
36
test/disposables/DisposableList.test.ts
Normal file
36
test/disposables/DisposableList.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type {Mock} from 'bun:test';
|
||||
import {mock, describe, it, beforeAll, beforeEach, expect} from 'bun:test';
|
||||
import {Disposable, DisposableList} from '../../src/disposables';
|
||||
|
||||
describe(`When using a DisposableList`, () => {
|
||||
let disposableList: DisposableList;
|
||||
|
||||
beforeEach(() => {
|
||||
disposableList = new DisposableList();
|
||||
});
|
||||
|
||||
describe(`Given a disposbale list with multiple disposables`, () => {
|
||||
let mocks: Array<Mock<any>>;
|
||||
let mockDisposables: Disposable[];
|
||||
|
||||
beforeEach(() => {
|
||||
mocks = [mock(() => {}), mock(() => {}), mock(() => {}), mock(() => {})];
|
||||
mockDisposables = mocks.map(mock => new Disposable(mock));
|
||||
mockDisposables.forEach(mockDisposable => disposableList.add(mockDisposable));
|
||||
});
|
||||
|
||||
describe(`Given the disposable list is disposed`, () => {
|
||||
beforeEach(() => {
|
||||
disposableList.dispose();
|
||||
});
|
||||
|
||||
it(`disposes all of the disposables in the list`, () => {
|
||||
mocks.forEach(mock => expect(mock).toHaveBeenCalled());
|
||||
});
|
||||
|
||||
it(`marks the disposable as disposed`, () => {
|
||||
mockDisposables.forEach(disposable => expect(disposable.isDisposed).toBeTrue());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user