mirror of
https://github.com/mathuo/dockview
synced 2025-08-28 04:56:22 +00:00
Add tests
This commit is contained in:
parent
809b7665f5
commit
86e8e63718
@ -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');
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user