Skip to content

Commit aa8e7e0

Browse files
authored
Merge pull request #481 from mathuo/469-add-window-lifecycle-callbacks-1
feat: provide means to obtain popoutWindow document
2 parents 47b691b + 20c1a66 commit aa8e7e0

29 files changed

+817
-495
lines changed

packages/dockview-core/src/__tests__/dnd/groupDragHandler.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('groupDragHandler', () => {
1111
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
1212
const partial: Partial<DockviewGroupPanel> = {
1313
id: 'test_group_id',
14-
api: { location: 'grid' } as any,
14+
api: { location: { type: 'grid' } } as any,
1515
};
1616
return partial as DockviewGroupPanel;
1717
});
@@ -53,7 +53,7 @@ describe('groupDragHandler', () => {
5353

5454
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
5555
const partial: Partial<DockviewGroupPanel> = {
56-
api: { location: 'floating' } as any,
56+
api: { location: { type: 'floating' } } as any,
5757
};
5858
return partial as DockviewGroupPanel;
5959
});
@@ -85,7 +85,7 @@ describe('groupDragHandler', () => {
8585

8686
const groupMock = jest.fn<DockviewGroupPanel, []>(() => {
8787
const partial: Partial<DockviewGroupPanel> = {
88-
api: { location: 'grid' } as any,
88+
api: { location: { type: 'grid' } } as any,
8989
};
9090
return partial as DockviewGroupPanel;
9191
});

packages/dockview-core/src/__tests__/dockview/components/titlebar/tabsContainer.spec.ts

+19-21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { DockviewGroupPanelModel } from '../../../../dockview/dockviewGroupPanel
99
import { fireEvent } from '@testing-library/dom';
1010
import { TestPanel } from '../../dockviewGroupPanelModel.spec';
1111
import { IDockviewPanel } from '../../../../dockview/dockviewPanel';
12+
import { fromPartial } from '@total-typescript/shoehorn';
1213

1314
describe('tabsContainer', () => {
1415
test('that an external event does not render a drop target and calls through to the group mode', () => {
@@ -478,7 +479,7 @@ describe('tabsContainer', () => {
478479

479480
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
480481
return (<Partial<DockviewGroupPanel>>{
481-
api: { location: 'grid' } as any,
482+
api: { location: { type: 'grid' } } as any,
482483
}) as DockviewGroupPanel;
483484
});
484485

@@ -538,7 +539,7 @@ describe('tabsContainer', () => {
538539

539540
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
540541
return (<Partial<DockviewGroupPanel>>{
541-
api: { location: 'floating' } as any,
542+
api: { location: { type: 'floating' } } as any,
542543
}) as DockviewGroupPanel;
543544
});
544545

@@ -591,7 +592,7 @@ describe('tabsContainer', () => {
591592

592593
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
593594
return (<Partial<DockviewGroupPanel>>{
594-
api: { location: 'floating' } as any,
595+
api: { location: { type: 'floating' } } as any,
595596
model: {} as any,
596597
}) as DockviewGroupPanel;
597598
});
@@ -601,23 +602,20 @@ describe('tabsContainer', () => {
601602

602603
const cut = new TabsContainer(accessor, groupPanel);
603604

604-
const panelMock = jest.fn<IDockviewPanel, [string]>((id: string) => {
605-
const partial: Partial<IDockviewPanel> = {
605+
const createPanel = (id: string) =>
606+
fromPartial<IDockviewPanel>({
606607
id,
607-
608608
view: {
609609
tab: {
610610
element: document.createElement('div'),
611-
} as any,
611+
},
612612
content: {
613613
element: document.createElement('div'),
614-
} as any,
615-
} as any,
616-
};
617-
return partial as IDockviewPanel;
618-
});
614+
},
615+
},
616+
});
619617

620-
const panel = new panelMock('test_id');
618+
const panel = createPanel('test_id');
621619
cut.openPanel(panel);
622620

623621
const el = cut.element.querySelector('.tab')!;
@@ -628,15 +626,15 @@ describe('tabsContainer', () => {
628626
fireEvent(el, event);
629627

630628
// a floating group with a single tab shouldn't be eligible
631-
expect(preventDefaultSpy).toBeCalledTimes(0);
632-
expect(accessor.addFloatingGroup).toBeCalledTimes(0);
629+
expect(preventDefaultSpy).toHaveBeenCalledTimes(0);
630+
expect(accessor.addFloatingGroup).toHaveBeenCalledTimes(0);
633631

634-
const panel2 = new panelMock('test_id_2');
632+
const panel2 = createPanel('test_id_2');
635633
cut.openPanel(panel2);
636634
fireEvent(el, event);
637635

638-
expect(preventDefaultSpy).toBeCalledTimes(1);
639-
expect(accessor.addFloatingGroup).toBeCalledTimes(1);
636+
expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
637+
expect(accessor.addFloatingGroup).toHaveBeenCalledTimes(1);
640638
});
641639

642640
test('pre header actions', () => {
@@ -653,7 +651,7 @@ describe('tabsContainer', () => {
653651

654652
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
655653
return (<Partial<DockviewGroupPanel>>{
656-
api: { location: 'grid' } as any,
654+
api: { location: { type: 'grid' } } as any,
657655
model: {} as any,
658656
}) as DockviewGroupPanel;
659657
});
@@ -723,7 +721,7 @@ describe('tabsContainer', () => {
723721

724722
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
725723
return (<Partial<DockviewGroupPanel>>{
726-
api: { location: 'grid' } as any,
724+
api: { location: { type: 'grid' } } as any,
727725
model: {} as any,
728726
}) as DockviewGroupPanel;
729727
});
@@ -793,7 +791,7 @@ describe('tabsContainer', () => {
793791

794792
const groupPanelMock = jest.fn<DockviewGroupPanel, []>(() => {
795793
return (<Partial<DockviewGroupPanel>>{
796-
api: { location: 'grid' } as any,
794+
api: { location: { type: 'grid' } } as any,
797795
model: {} as any,
798796
}) as DockviewGroupPanel;
799797
});

0 commit comments

Comments
 (0)