Skip to content

Commit 73058db

Browse files
committed
Merge branch 'master' of https://github.com/mathuo/dockview into 475-improved-docs
2 parents 3952ae5 + aa8e7e0 commit 73058db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+898
-541
lines changed

packages/dockview-core/src/__tests__/api/dockviewPanelApi.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('groupPanelApi', () => {
88
const accessor: Partial<DockviewComponent> = {
99
onDidAddPanel: jest.fn(),
1010
onDidRemovePanel: jest.fn(),
11-
options: {},
11+
options: { parentElement: document.createElement('div') },
1212
};
1313

1414
const panelMock = jest.fn<DockviewPanel, []>(() => {
@@ -44,7 +44,7 @@ describe('groupPanelApi', () => {
4444
const accessor: Partial<DockviewComponent> = {
4545
onDidAddPanel: jest.fn(),
4646
onDidRemovePanel: jest.fn(),
47-
options: {},
47+
options: { parentElement: document.createElement('div') },
4848
};
4949
const groupViewPanel = new DockviewGroupPanel(
5050
<DockviewComponent>accessor,
@@ -74,7 +74,7 @@ describe('groupPanelApi', () => {
7474
const accessor: Partial<DockviewComponent> = {
7575
onDidAddPanel: jest.fn(),
7676
onDidRemovePanel: jest.fn(),
77-
options: {},
77+
options: { parentElement: document.createElement('div') },
7878
};
7979
const groupViewPanel = new DockviewGroupPanel(
8080
<DockviewComponent>accessor,

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

+36-38
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ 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', () => {
1516
const accessorMock = jest.fn<Partial<DockviewComponent>, []>(() => {
1617
return {
1718
onDidAddPanel: jest.fn(),
1819
onDidRemovePanel: jest.fn(),
19-
options: {},
20+
options: { parentElement: document.createElement('div') },
2021
};
2122
});
2223
const groupviewMock = jest.fn<Partial<DockviewGroupPanelModel>, []>(
@@ -71,7 +72,7 @@ describe('tabsContainer', () => {
7172
id: 'testcomponentid',
7273
onDidAddPanel: jest.fn(),
7374
onDidRemovePanel: jest.fn(),
74-
options: {},
75+
options: { parentElement: document.createElement('div') },
7576
};
7677
});
7778
const groupviewMock = jest.fn<Partial<DockviewGroupPanelModel>, []>(
@@ -139,7 +140,7 @@ describe('tabsContainer', () => {
139140
id: 'testcomponentid',
140141
onDidAddPanel: jest.fn(),
141142
onDidRemovePanel: jest.fn(),
142-
options: {},
143+
options: { parentElement: document.createElement('div') },
143144
};
144145
});
145146
const groupviewMock = jest.fn<Partial<DockviewGroupPanelModel>, []>(
@@ -204,7 +205,7 @@ describe('tabsContainer', () => {
204205
id: 'testcomponentid',
205206
onDidAddPanel: jest.fn(),
206207
onDidRemovePanel: jest.fn(),
207-
options: {},
208+
options: { parentElement: document.createElement('div') },
208209
};
209210
});
210211
const groupviewMock = jest.fn<Partial<DockviewGroupPanelModel>, []>(
@@ -269,7 +270,7 @@ describe('tabsContainer', () => {
269270
id: 'testcomponentid',
270271
onDidAddPanel: jest.fn(),
271272
onDidRemovePanel: jest.fn(),
272-
options: {},
273+
options: { parentElement: document.createElement('div') },
273274
};
274275
});
275276
const groupviewMock = jest.fn<Partial<DockviewGroupPanelModel>, []>(
@@ -336,7 +337,7 @@ describe('tabsContainer', () => {
336337
test('left actions', () => {
337338
const accessorMock = jest.fn<DockviewComponent, []>(() => {
338339
return (<Partial<DockviewComponent>>{
339-
options: {},
340+
options: { parentElement: document.createElement('div') },
340341
onDidAddPanel: jest.fn(),
341342
onDidRemovePanel: jest.fn(),
342343
}) as DockviewComponent;
@@ -402,7 +403,7 @@ describe('tabsContainer', () => {
402403
test('right actions', () => {
403404
const accessorMock = jest.fn<DockviewComponent, []>(() => {
404405
return (<Partial<DockviewComponent>>{
405-
options: {},
406+
options: { parentElement: document.createElement('div') },
406407
onDidAddPanel: jest.fn(),
407408
onDidRemovePanel: jest.fn(),
408409
}) as DockviewComponent;
@@ -468,7 +469,7 @@ describe('tabsContainer', () => {
468469
test('that a tab will become floating when clicked if not floating and shift is selected', () => {
469470
const accessorMock = jest.fn<DockviewComponent, []>(() => {
470471
return (<Partial<DockviewComponent>>{
471-
options: {},
472+
options: { parentElement: document.createElement('div') },
472473
onDidAddPanel: jest.fn(),
473474
onDidRemovePanel: jest.fn(),
474475
element: document.createElement('div'),
@@ -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

@@ -514,21 +515,21 @@ describe('tabsContainer', () => {
514515
},
515516
{ inDragMode: true }
516517
);
517-
expect(accessor.addFloatingGroup).toBeCalledTimes(1);
518-
expect(eventPreventDefaultSpy).toBeCalledTimes(1);
518+
expect(accessor.addFloatingGroup).toHaveBeenCalledTimes(1);
519+
expect(eventPreventDefaultSpy).toHaveBeenCalledTimes(1);
519520

520521
const event2 = new KeyboardEvent('mousedown', { shiftKey: false });
521522
const eventPreventDefaultSpy2 = jest.spyOn(event2, 'preventDefault');
522523
fireEvent(container, event2);
523524

524-
expect(accessor.addFloatingGroup).toBeCalledTimes(1);
525-
expect(eventPreventDefaultSpy2).toBeCalledTimes(0);
525+
expect(accessor.addFloatingGroup).toHaveBeenCalledTimes(1);
526+
expect(eventPreventDefaultSpy2).toHaveBeenCalledTimes(0);
526527
});
527528

528529
test('that a tab that is already floating cannot be floated again', () => {
529530
const accessorMock = jest.fn<DockviewComponent, []>(() => {
530531
return (<Partial<DockviewComponent>>{
531-
options: {},
532+
options: { parentElement: document.createElement('div') },
532533
onDidAddPanel: jest.fn(),
533534
onDidRemovePanel: jest.fn(),
534535
element: document.createElement('div'),
@@ -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

@@ -580,7 +581,7 @@ describe('tabsContainer', () => {
580581
test('that selecting a tab with shift down will move that tab into a new floating group', () => {
581582
const accessorMock = jest.fn<DockviewComponent, []>(() => {
582583
return (<Partial<DockviewComponent>>{
583-
options: {},
584+
options: { parentElement: document.createElement('div') },
584585
onDidAddPanel: jest.fn(),
585586
onDidRemovePanel: jest.fn(),
586587
element: document.createElement('div'),
@@ -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,21 +626,21 @@ 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', () => {
643641
const accessorMock = jest.fn<DockviewComponent, []>(() => {
644642
return (<Partial<DockviewComponent>>{
645-
options: {},
643+
options: { parentElement: document.createElement('div') },
646644
onDidAddPanel: jest.fn(),
647645
onDidRemovePanel: jest.fn(),
648646
element: document.createElement('div'),
@@ -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
});
@@ -712,7 +710,7 @@ describe('tabsContainer', () => {
712710
test('left header actions', () => {
713711
const accessorMock = jest.fn<DockviewComponent, []>(() => {
714712
return (<Partial<DockviewComponent>>{
715-
options: {},
713+
options: { parentElement: document.createElement('div') },
716714
onDidAddPanel: jest.fn(),
717715
onDidRemovePanel: jest.fn(),
718716
element: document.createElement('div'),
@@ -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
});
@@ -782,7 +780,7 @@ describe('tabsContainer', () => {
782780
test('right header actions', () => {
783781
const accessorMock = jest.fn<DockviewComponent, []>(() => {
784782
return (<Partial<DockviewComponent>>{
785-
options: {},
783+
options: { parentElement: document.createElement('div') },
786784
onDidAddPanel: jest.fn(),
787785
onDidRemovePanel: jest.fn(),
788786
element: document.createElement('div'),
@@ -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)