mirror of
https://github.com/mathuo/dockview
synced 2025-05-04 18:48:26 +00:00
Merge pull request #29 from mathuo/23-increase-test-coverage
tests: add tests
This commit is contained in:
commit
0d9abc4937
135
packages/dockview/src/__tests__/api/component.api.spec.ts
Normal file
135
packages/dockview/src/__tests__/api/component.api.spec.ts
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
import { DockviewComponent } from '../..';
|
||||||
|
import {
|
||||||
|
SplitviewApi,
|
||||||
|
PaneviewApi,
|
||||||
|
GridviewApi,
|
||||||
|
DockviewApi,
|
||||||
|
} from '../../api/component.api';
|
||||||
|
import { GridviewComponent } from '../../gridview/gridviewComponent';
|
||||||
|
import { PaneviewComponent } from '../../paneview/paneviewComponent';
|
||||||
|
import { SplitviewComponent } from '../../splitview/splitviewComponent';
|
||||||
|
|
||||||
|
describe('component.api', () => {
|
||||||
|
describe('splitview', () => {
|
||||||
|
test('splitviewapi', () => {
|
||||||
|
const list: (keyof SplitviewComponent)[] = [
|
||||||
|
'minimumSize',
|
||||||
|
'maximumSize',
|
||||||
|
'height',
|
||||||
|
'width',
|
||||||
|
'length',
|
||||||
|
'orientation',
|
||||||
|
'onDidLayoutChange',
|
||||||
|
'onDidAddView',
|
||||||
|
'onDidRemoveView',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const _ of list) {
|
||||||
|
const f = jest.fn();
|
||||||
|
|
||||||
|
const component: Partial<SplitviewComponent> = {
|
||||||
|
[_]: f(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const cut = new SplitviewApi(<SplitviewComponent>component);
|
||||||
|
|
||||||
|
expect((cut as any)[_]).toBeFalsy();
|
||||||
|
|
||||||
|
expect(f).toBeCalledTimes(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('paneview', () => {
|
||||||
|
test('panviewapi', () => {
|
||||||
|
const list: (keyof PaneviewComponent)[] = [
|
||||||
|
'minimumSize',
|
||||||
|
'maximumSize',
|
||||||
|
'height',
|
||||||
|
'width',
|
||||||
|
'onDidLayoutChange',
|
||||||
|
'onDidAddView',
|
||||||
|
'onDidRemoveView',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const _ of list) {
|
||||||
|
const f = jest.fn();
|
||||||
|
|
||||||
|
const component: Partial<PaneviewComponent> = {
|
||||||
|
[_]: f(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const cut = new PaneviewApi(<PaneviewComponent>component);
|
||||||
|
|
||||||
|
expect((cut as any)[_]).toBeFalsy();
|
||||||
|
|
||||||
|
expect(f).toBeCalledTimes(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('gridview', () => {
|
||||||
|
test('gridviewapi', () => {
|
||||||
|
const list: (keyof GridviewComponent)[] = [
|
||||||
|
'minimumHeight',
|
||||||
|
'maximumHeight',
|
||||||
|
'minimumWidth',
|
||||||
|
'maximumWidth',
|
||||||
|
'width',
|
||||||
|
'height',
|
||||||
|
'onGridEvent',
|
||||||
|
'onDidLayoutChange',
|
||||||
|
'orientation',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const _ of list) {
|
||||||
|
const f = jest.fn();
|
||||||
|
|
||||||
|
const component: Partial<GridviewComponent> = {
|
||||||
|
[_]: f(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const cut = new GridviewApi(<GridviewComponent>component);
|
||||||
|
|
||||||
|
expect((cut as any)[_]).toBeFalsy();
|
||||||
|
|
||||||
|
expect(f).toBeCalledTimes(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('dockview', () => {
|
||||||
|
test('dockviewapi', () => {
|
||||||
|
const list: (keyof DockviewComponent)[] = [
|
||||||
|
'minimumHeight',
|
||||||
|
'maximumHeight',
|
||||||
|
'minimumWidth',
|
||||||
|
'maximumWidth',
|
||||||
|
'width',
|
||||||
|
'height',
|
||||||
|
'size',
|
||||||
|
'totalPanels',
|
||||||
|
'onGridEvent',
|
||||||
|
'onDidLayoutChange',
|
||||||
|
'panels',
|
||||||
|
'groups',
|
||||||
|
'activeGroup',
|
||||||
|
'activePanel',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const _ of list) {
|
||||||
|
const f = jest.fn();
|
||||||
|
|
||||||
|
const component: Partial<DockviewComponent> = {
|
||||||
|
[_]: f(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const cut = new DockviewApi(<DockviewComponent>component);
|
||||||
|
|
||||||
|
expect((cut as any)[_]).toBeFalsy();
|
||||||
|
|
||||||
|
expect(f).toBeCalledTimes(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -64,6 +64,10 @@ export class SplitviewApi implements CommonApi {
|
|||||||
return this.component.length;
|
return this.component.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get orientation(): Orientation {
|
||||||
|
return this.component.orientation;
|
||||||
|
}
|
||||||
|
|
||||||
get onDidLayoutChange(): Event<void> {
|
get onDidLayoutChange(): Event<void> {
|
||||||
return this.component.onDidLayoutChange;
|
return this.component.onDidLayoutChange;
|
||||||
}
|
}
|
||||||
@ -76,10 +80,6 @@ export class SplitviewApi implements CommonApi {
|
|||||||
return this.component.onDidRemoveView;
|
return this.component.onDidRemoveView;
|
||||||
}
|
}
|
||||||
|
|
||||||
get orientation(): Orientation {
|
|
||||||
return this.component.orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(private readonly component: ISplitviewComponent) {}
|
constructor(private readonly component: ISplitviewComponent) {}
|
||||||
|
|
||||||
updateOptions(options: SplitviewComponentUpdateOptions): void {
|
updateOptions(options: SplitviewComponentUpdateOptions): void {
|
||||||
@ -136,14 +136,6 @@ export class SplitviewApi implements CommonApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class PaneviewApi implements CommonApi {
|
export class PaneviewApi implements CommonApi {
|
||||||
get width(): number {
|
|
||||||
return this.component.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
get height(): number {
|
|
||||||
return this.component.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
get minimumSize(): number {
|
get minimumSize(): number {
|
||||||
return this.component.minimumSize;
|
return this.component.minimumSize;
|
||||||
}
|
}
|
||||||
@ -152,6 +144,14 @@ export class PaneviewApi implements CommonApi {
|
|||||||
return this.component.maximumSize;
|
return this.component.maximumSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get height(): number {
|
||||||
|
return this.component.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
get width(): number {
|
||||||
|
return this.component.width;
|
||||||
|
}
|
||||||
|
|
||||||
get onDidLayoutChange(): Event<void> {
|
get onDidLayoutChange(): Event<void> {
|
||||||
return this.component.onDidLayoutChange;
|
return this.component.onDidLayoutChange;
|
||||||
}
|
}
|
||||||
@ -223,14 +223,6 @@ export class PaneviewApi implements CommonApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GridviewApi implements CommonApi {
|
export class GridviewApi implements CommonApi {
|
||||||
get width(): number {
|
|
||||||
return this.component.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
get height(): number {
|
|
||||||
return this.component.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
get minimumHeight(): number {
|
get minimumHeight(): number {
|
||||||
return this.component.minimumHeight;
|
return this.component.minimumHeight;
|
||||||
}
|
}
|
||||||
@ -247,6 +239,14 @@ export class GridviewApi implements CommonApi {
|
|||||||
return this.component.maximumWidth;
|
return this.component.maximumWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get width(): number {
|
||||||
|
return this.component.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
get height(): number {
|
||||||
|
return this.component.height;
|
||||||
|
}
|
||||||
|
|
||||||
get onGridEvent(): Event<GroupChangeEvent> {
|
get onGridEvent(): Event<GroupChangeEvent> {
|
||||||
return this.component.onGridEvent;
|
return this.component.onGridEvent;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user