Add tests

This commit is contained in:
Mathias Borglin 2025-05-11 21:42:39 +02:00
parent 809b7665f5
commit 86e8e63718
2 changed files with 51 additions and 1 deletions

View File

@ -5791,6 +5791,54 @@ describe('dockviewComponent', () => {
]);
});
describe('when browsers block popups', () => {
let container: HTMLDivElement;
let dockview: DockviewComponent;
let panel: DockviewPanel;
beforeEach(() => {
jest.spyOn(window, 'open').mockReturnValue(null);
container = document.createElement('div');
dockview = new DockviewComponent(container, {
createComponent(options) {
switch (options.name) {
case 'default':
return new PanelContentPartTest(
options.id,
options.name
);
default:
throw new Error(`unsupported`);
}
},
});
dockview.layout(1000, 500);
panel = dockview.addPanel({
id: 'panel_1',
component: 'default',
});
});
test('onDidBlockPopout event is emitted', async () => {
const onDidBlockPopoutHandler = jest.fn();
dockview.onDidBlockPopout(onDidBlockPopoutHandler);
await dockview.addPopoutGroup(panel.group);
expect(onDidBlockPopoutHandler).toHaveBeenCalledTimes(1);
});
test('popout group is restored to its original position', async () => {
await dockview.addPopoutGroup(panel.group);
expect(panel.group.api.location.type).toBe('grid');
});
});
test('dispose of dockview instance when popup is open', async () => {
const container = document.createElement('div');

View File

@ -738,7 +738,9 @@ export class DockviewComponent
group = options.overridePopoutGroup;
} else {
group = this.createGroup({ id: groupId });
this._onDidAddGroup.fire(group);
if (popoutContainer) {
this._onDidAddGroup.fire(group);
}
}
if (popoutContainer === null) {