mirror of
https://github.com/mathuo/dockview
synced 2025-02-22 16:15:45 +00:00
tests: add tests
This commit is contained in:
parent
b43a4b9d06
commit
e8a7157d45
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;
|
||||
}
|
||||
|
||||
get orientation(): Orientation {
|
||||
return this.component.orientation;
|
||||
}
|
||||
|
||||
get onDidLayoutChange(): Event<void> {
|
||||
return this.component.onDidLayoutChange;
|
||||
}
|
||||
@ -76,10 +80,6 @@ export class SplitviewApi implements CommonApi {
|
||||
return this.component.onDidRemoveView;
|
||||
}
|
||||
|
||||
get orientation(): Orientation {
|
||||
return this.component.orientation;
|
||||
}
|
||||
|
||||
constructor(private readonly component: ISplitviewComponent) {}
|
||||
|
||||
updateOptions(options: SplitviewComponentUpdateOptions): void {
|
||||
@ -136,14 +136,6 @@ export class SplitviewApi implements CommonApi {
|
||||
}
|
||||
|
||||
export class PaneviewApi implements CommonApi {
|
||||
get width(): number {
|
||||
return this.component.width;
|
||||
}
|
||||
|
||||
get height(): number {
|
||||
return this.component.height;
|
||||
}
|
||||
|
||||
get minimumSize(): number {
|
||||
return this.component.minimumSize;
|
||||
}
|
||||
@ -152,6 +144,14 @@ export class PaneviewApi implements CommonApi {
|
||||
return this.component.maximumSize;
|
||||
}
|
||||
|
||||
get height(): number {
|
||||
return this.component.height;
|
||||
}
|
||||
|
||||
get width(): number {
|
||||
return this.component.width;
|
||||
}
|
||||
|
||||
get onDidLayoutChange(): Event<void> {
|
||||
return this.component.onDidLayoutChange;
|
||||
}
|
||||
@ -223,14 +223,6 @@ export class PaneviewApi implements CommonApi {
|
||||
}
|
||||
|
||||
export class GridviewApi implements CommonApi {
|
||||
get width(): number {
|
||||
return this.component.width;
|
||||
}
|
||||
|
||||
get height(): number {
|
||||
return this.component.height;
|
||||
}
|
||||
|
||||
get minimumHeight(): number {
|
||||
return this.component.minimumHeight;
|
||||
}
|
||||
@ -247,6 +239,14 @@ export class GridviewApi implements CommonApi {
|
||||
return this.component.maximumWidth;
|
||||
}
|
||||
|
||||
get width(): number {
|
||||
return this.component.width;
|
||||
}
|
||||
|
||||
get height(): number {
|
||||
return this.component.height;
|
||||
}
|
||||
|
||||
get onGridEvent(): Event<GroupChangeEvent> {
|
||||
return this.component.onGridEvent;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user