mirror of
https://github.com/mathuo/dockview
synced 2025-02-21 15:45:46 +00:00
tests: add tests
This commit is contained in:
parent
0d9abc4937
commit
9608ec957d
@ -22,6 +22,10 @@ describe('component.api', () => {
|
||||
'onDidLayoutChange',
|
||||
'onDidAddView',
|
||||
'onDidRemoveView',
|
||||
'getPanels',
|
||||
'focus',
|
||||
'resizeToFit',
|
||||
'toJSON',
|
||||
];
|
||||
|
||||
for (const _ of list) {
|
||||
@ -33,7 +37,7 @@ describe('component.api', () => {
|
||||
|
||||
const cut = new SplitviewApi(<SplitviewComponent>component);
|
||||
|
||||
expect((cut as any)[_]).toBeFalsy();
|
||||
(cut as any)[_];
|
||||
|
||||
expect(f).toBeCalledTimes(1);
|
||||
}
|
||||
@ -50,6 +54,10 @@ describe('component.api', () => {
|
||||
'onDidLayoutChange',
|
||||
'onDidAddView',
|
||||
'onDidRemoveView',
|
||||
'getPanels',
|
||||
'focus',
|
||||
'resizeToFit',
|
||||
'toJSON',
|
||||
];
|
||||
|
||||
for (const _ of list) {
|
||||
@ -61,7 +69,7 @@ describe('component.api', () => {
|
||||
|
||||
const cut = new PaneviewApi(<PaneviewComponent>component);
|
||||
|
||||
expect((cut as any)[_]).toBeFalsy();
|
||||
(cut as any)[_];
|
||||
|
||||
expect(f).toBeCalledTimes(1);
|
||||
}
|
||||
@ -80,6 +88,9 @@ describe('component.api', () => {
|
||||
'onGridEvent',
|
||||
'onDidLayoutChange',
|
||||
'orientation',
|
||||
'focus',
|
||||
'resizeToFit',
|
||||
'toJSON',
|
||||
];
|
||||
|
||||
for (const _ of list) {
|
||||
@ -91,7 +102,7 @@ describe('component.api', () => {
|
||||
|
||||
const cut = new GridviewApi(<GridviewComponent>component);
|
||||
|
||||
expect((cut as any)[_]).toBeFalsy();
|
||||
(cut as any)[_];
|
||||
|
||||
expect(f).toBeCalledTimes(1);
|
||||
}
|
||||
@ -115,6 +126,10 @@ describe('component.api', () => {
|
||||
'groups',
|
||||
'activeGroup',
|
||||
'activePanel',
|
||||
'focus',
|
||||
'closeAllGroups',
|
||||
'resizeToFit',
|
||||
'toJSON',
|
||||
];
|
||||
|
||||
for (const _ of list) {
|
||||
@ -126,7 +141,7 @@ describe('component.api', () => {
|
||||
|
||||
const cut = new DockviewApi(<DockviewComponent>component);
|
||||
|
||||
expect((cut as any)[_]).toBeFalsy();
|
||||
(cut as any)[_];
|
||||
|
||||
expect(f).toBeCalledTimes(1);
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { IDockviewComponent } from '../../dockview/dockviewComponent';
|
||||
import {
|
||||
IDockviewComponent,
|
||||
DockviewComponent,
|
||||
} from '../../dockview/dockviewComponent';
|
||||
import {
|
||||
GroupviewPanelState,
|
||||
IGroupPanel,
|
||||
@ -198,13 +201,21 @@ describe('groupview', () => {
|
||||
let dockview: IDockviewComponent;
|
||||
let options: GroupOptions;
|
||||
|
||||
let removePanelMock: jest.Mock;
|
||||
let removeGroupMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
dockview = <IDockviewComponent>(<any>{
|
||||
removePanelMock = jest.fn();
|
||||
removeGroupMock = jest.fn();
|
||||
|
||||
dockview = (<Partial<DockviewComponent>>{
|
||||
options: {},
|
||||
createWatermarkComponent: () => new Watermark(),
|
||||
doSetGroupActive: jest.fn(),
|
||||
id: 'dockview-1',
|
||||
});
|
||||
removePanel: removePanelMock,
|
||||
removeGroup: removeGroupMock,
|
||||
}) as DockviewComponent;
|
||||
|
||||
options = {
|
||||
tabHeight: 30,
|
||||
@ -412,4 +423,25 @@ describe('groupview', () => {
|
||||
);
|
||||
expect(viewQuery).toBeTruthy();
|
||||
});
|
||||
|
||||
test('closeAllPanels with panels', () => {
|
||||
const panel1 = new TestPanel('panel1', jest.fn() as any);
|
||||
const panel2 = new TestPanel('panel2', jest.fn() as any);
|
||||
const panel3 = new TestPanel('panel3', jest.fn() as any);
|
||||
|
||||
groupview.model.openPanel(panel1);
|
||||
groupview.model.openPanel(panel2);
|
||||
groupview.model.openPanel(panel3);
|
||||
|
||||
groupview.model.closeAllPanels();
|
||||
|
||||
expect(removePanelMock).toBeCalledWith(panel1);
|
||||
expect(removePanelMock).toBeCalledWith(panel2);
|
||||
expect(removePanelMock).toBeCalledWith(panel3);
|
||||
});
|
||||
|
||||
test('closeAllPanels with no panels', () => {
|
||||
groupview.model.closeAllPanels();
|
||||
expect(removeGroupMock).toBeCalledWith(groupview);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user