mirror of
https://github.com/mathuo/dockview
synced 2025-03-12 08:52:05 +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', () => {
|
describe('lifecycle', () => {
|
||||||
test('mutable disposable', () => {
|
test('mutable disposable', () => {
|
||||||
@ -64,4 +68,16 @@ describe('lifecycle', () => {
|
|||||||
|
|
||||||
expect(cut.checkIsDisposed()).toBeTruthy();
|
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 { directionToPosition, Droptarget, Position } from '../dnd/droptarget';
|
||||||
import { tail, sequenceEquals, remove } from '../array';
|
import { tail, sequenceEquals, remove } from '../array';
|
||||||
import { DockviewPanel, IDockviewPanel } from './dockviewPanel';
|
import { DockviewPanel, IDockviewPanel } from './dockviewPanel';
|
||||||
import { CompositeDisposable } from '../lifecycle';
|
import { CompositeDisposable, Disposable } from '../lifecycle';
|
||||||
import { Event, Emitter } from '../events';
|
import { Event, Emitter } from '../events';
|
||||||
import { Watermark } from './components/watermark/watermark';
|
import { Watermark } from './components/watermark/watermark';
|
||||||
import {
|
import {
|
||||||
@ -58,7 +58,10 @@ import {
|
|||||||
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
||||||
DEFAULT_FLOATING_GROUP_POSITION,
|
DEFAULT_FLOATING_GROUP_POSITION,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import { DockviewPanelRenderer, OverlayRenderContainer } from '../overlayRenderContainer';
|
import {
|
||||||
|
DockviewPanelRenderer,
|
||||||
|
OverlayRenderContainer,
|
||||||
|
} from '../overlayRenderContainer';
|
||||||
|
|
||||||
function getTheme(element: HTMLElement): string | undefined {
|
function getTheme(element: HTMLElement): string | undefined {
|
||||||
function toClassList(element: HTMLElement) {
|
function toClassList(element: HTMLElement) {
|
||||||
@ -386,6 +389,17 @@ export class DockviewComponent
|
|||||||
this.onDidActivePanelChange
|
this.onDidActivePanelChange
|
||||||
)(() => {
|
)(() => {
|
||||||
this._bufferOnDidLayoutChange.fire();
|
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
|
// noop
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function from(func: () => void): IDisposable {
|
||||||
|
return {
|
||||||
|
dispose: () => {
|
||||||
|
func();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CompositeDisposable {
|
export class CompositeDisposable {
|
||||||
|
@ -75,10 +75,7 @@ export class PopoutWindow extends CompositeDisposable {
|
|||||||
|
|
||||||
this._window = { value: externalWindow, disposable };
|
this._window = { value: externalWindow, disposable };
|
||||||
|
|
||||||
const grievingParent = content.parentElement;
|
|
||||||
|
|
||||||
const cleanUp = () => {
|
const cleanUp = () => {
|
||||||
grievingParent?.appendChild(content);
|
|
||||||
this._onDidClose.fire();
|
this._onDidClose.fire();
|
||||||
this._window = null;
|
this._window = null;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user