mirror of
https://github.com/mathuo/dockview
synced 2025-03-11 16:32:06 +00:00
test: add tests
This commit is contained in:
parent
4b616c5578
commit
aa6eb27d7d
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,8 @@
|
||||
import { CompositeDisposable, MutableDisposable } from '../lifecycle';
|
||||
import {
|
||||
CompositeDisposable,
|
||||
Disposable,
|
||||
MutableDisposable,
|
||||
} from '../lifecycle';
|
||||
|
||||
describe('lifecycle', () => {
|
||||
test('mutable disposable', () => {
|
||||
@ -64,4 +68,16 @@ describe('lifecycle', () => {
|
||||
|
||||
expect(cut.checkIsDisposed()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Disposable.from(...)', () => {
|
||||
const func = jest.fn();
|
||||
|
||||
const disposable = Disposable.from(func);
|
||||
|
||||
expect(func).not.toHaveBeenCalled();
|
||||
|
||||
disposable.dispose();
|
||||
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
import { directionToPosition, Droptarget, Position } from '../dnd/droptarget';
|
||||
import { tail, sequenceEquals, remove } from '../array';
|
||||
import { DockviewPanel, IDockviewPanel } from './dockviewPanel';
|
||||
import { CompositeDisposable } from '../lifecycle';
|
||||
import { CompositeDisposable, Disposable } from '../lifecycle';
|
||||
import { Event, Emitter } from '../events';
|
||||
import { Watermark } from './components/watermark/watermark';
|
||||
import {
|
||||
@ -58,7 +58,10 @@ import {
|
||||
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
||||
DEFAULT_FLOATING_GROUP_POSITION,
|
||||
} from '../constants';
|
||||
import { DockviewPanelRenderer, OverlayRenderContainer } from '../overlayRenderContainer';
|
||||
import {
|
||||
DockviewPanelRenderer,
|
||||
OverlayRenderContainer,
|
||||
} from '../overlayRenderContainer';
|
||||
|
||||
function getTheme(element: HTMLElement): string | undefined {
|
||||
function toClassList(element: HTMLElement) {
|
||||
@ -386,6 +389,17 @@ export class DockviewComponent
|
||||
this.onDidActivePanelChange
|
||||
)(() => {
|
||||
this._bufferOnDidLayoutChange.fire();
|
||||
}),
|
||||
Disposable.from(() => {
|
||||
// iterate over a copy of the array since .dispose() mutates the original array
|
||||
for (const group of [...this._floatingGroups]) {
|
||||
group.dispose();
|
||||
}
|
||||
|
||||
// iterate over a copy of the array since .dispose() mutates the original array
|
||||
for (const group of [...this._popoutGroups]) {
|
||||
group.dispose();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -13,6 +13,14 @@ export namespace Disposable {
|
||||
// noop
|
||||
},
|
||||
};
|
||||
|
||||
export function from(func: () => void): IDisposable {
|
||||
return {
|
||||
dispose: () => {
|
||||
func();
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class CompositeDisposable {
|
||||
|
@ -75,10 +75,7 @@ export class PopoutWindow extends CompositeDisposable {
|
||||
|
||||
this._window = { value: externalWindow, disposable };
|
||||
|
||||
const grievingParent = content.parentElement;
|
||||
|
||||
const cleanUp = () => {
|
||||
grievingParent?.appendChild(content);
|
||||
this._onDidClose.fire();
|
||||
this._window = null;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user