mirror of
https://github.com/mathuo/dockview
synced 2025-01-22 17:35:57 +00:00
test: adjust tsconfig for tests
This commit is contained in:
parent
575a1d7031
commit
ec341f0706
@ -20,6 +20,14 @@ const config: JestConfigWithTsJest = {
|
|||||||
coverageDirectory: '<rootDir>/packages/dockview-core/coverage/',
|
coverageDirectory: '<rootDir>/packages/dockview-core/coverage/',
|
||||||
testResultsProcessor: 'jest-sonar-reporter',
|
testResultsProcessor: 'jest-sonar-reporter',
|
||||||
testEnvironment: 'jsdom',
|
testEnvironment: 'jsdom',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.tsx?$': [
|
||||||
|
'ts-jest',
|
||||||
|
{
|
||||||
|
tsconfig: '<rootDir>/tsconfig.test.json',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
@ -114,7 +114,7 @@ describe('baseComponentGridview', () => {
|
|||||||
proportionalLayout: true,
|
proportionalLayout: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const events: TestPanel[] = [];
|
const events: (TestPanel | undefined)[] = [];
|
||||||
|
|
||||||
const disposable = new CompositeDisposable(
|
const disposable = new CompositeDisposable(
|
||||||
cut.onDidAddGroup((event) => {
|
cut.onDidAddGroup((event) => {
|
||||||
|
@ -18,11 +18,9 @@ import { LocalSelectionTransfer, PanelTransfer } from '../../dnd/dataTransfer';
|
|||||||
import { CompositeDisposable } from '../../lifecycle';
|
import { CompositeDisposable } from '../../lifecycle';
|
||||||
import { DockviewPanelApi } from '../../api/dockviewPanelApi';
|
import { DockviewPanelApi } from '../../api/dockviewPanelApi';
|
||||||
import { IDockviewPanel } from '../../dockview/dockviewPanel';
|
import { IDockviewPanel } from '../../dockview/dockviewPanel';
|
||||||
import {
|
import { IDockviewPanelModel } from '../../dockview/dockviewPanelModel';
|
||||||
IDockviewPanelModel,
|
|
||||||
DockviewPanelModel,
|
|
||||||
} from '../../dockview/dockviewPanelModel';
|
|
||||||
import { DockviewGroupPanel } from '../../dockview/dockviewGroupPanel';
|
import { DockviewGroupPanel } from '../../dockview/dockviewGroupPanel';
|
||||||
|
import { WatermarkRendererInitParameters } from '../../dockview/types';
|
||||||
|
|
||||||
enum GroupChangeKind2 {
|
enum GroupChangeKind2 {
|
||||||
ADD_PANEL,
|
ADD_PANEL,
|
||||||
@ -76,7 +74,7 @@ class Watermark implements IWatermarkRenderer {
|
|||||||
return 'watermark-id';
|
return 'watermark-id';
|
||||||
}
|
}
|
||||||
|
|
||||||
init(params: GroupPanelPartInitParameters) {
|
init(params: WatermarkRendererInitParameters) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +168,7 @@ class TestHeaderPart implements ITabRenderer {
|
|||||||
|
|
||||||
export class TestPanel implements IDockviewPanel {
|
export class TestPanel implements IDockviewPanel {
|
||||||
private _group: DockviewGroupPanel | undefined;
|
private _group: DockviewGroupPanel | undefined;
|
||||||
private _params: IGroupPanelInitParameters;
|
private _params: IGroupPanelInitParameters | undefined;
|
||||||
readonly view: IDockviewPanelModel;
|
readonly view: IDockviewPanelModel;
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
@ -516,7 +514,7 @@ describe('groupview', () => {
|
|||||||
dockviewComponent,
|
dockviewComponent,
|
||||||
'id',
|
'id',
|
||||||
{},
|
{},
|
||||||
null
|
null as any
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(cut.toJSON()).toEqual({
|
expect(cut.toJSON()).toEqual({
|
||||||
@ -539,7 +537,7 @@ describe('groupview', () => {
|
|||||||
dockviewComponent,
|
dockviewComponent,
|
||||||
'id',
|
'id',
|
||||||
{},
|
{},
|
||||||
null
|
null as any
|
||||||
);
|
);
|
||||||
|
|
||||||
cut.locked = true;
|
cut.locked = true;
|
||||||
@ -568,25 +566,25 @@ describe('groupview', () => {
|
|||||||
dockviewComponent,
|
dockviewComponent,
|
||||||
'id',
|
'id',
|
||||||
{},
|
{},
|
||||||
null
|
null as any
|
||||||
);
|
);
|
||||||
const contentContainer = groupviewContainer
|
const contentContainer = groupviewContainer
|
||||||
.getElementsByClassName('content-container')
|
.getElementsByClassName('content-container')
|
||||||
.item(0)!.childNodes;
|
.item(0)!.childNodes;
|
||||||
|
|
||||||
const panel1 = new TestPanel('id_1', null);
|
const panel1 = new TestPanel('id_1', null as any);
|
||||||
|
|
||||||
cut.openPanel(panel1);
|
cut.openPanel(panel1);
|
||||||
expect(contentContainer.length).toBe(1);
|
expect(contentContainer.length).toBe(1);
|
||||||
expect(contentContainer.item(0)).toBe(panel1.view.content.element);
|
expect(contentContainer.item(0)).toBe(panel1.view.content.element);
|
||||||
|
|
||||||
const panel2 = new TestPanel('id_2', null);
|
const panel2 = new TestPanel('id_2', null as any);
|
||||||
|
|
||||||
cut.openPanel(panel2);
|
cut.openPanel(panel2);
|
||||||
expect(contentContainer.length).toBe(1);
|
expect(contentContainer.length).toBe(1);
|
||||||
expect(contentContainer.item(0)).toBe(panel2.view.content.element);
|
expect(contentContainer.item(0)).toBe(panel2.view.content.element);
|
||||||
|
|
||||||
const panel3 = new TestPanel('id_2', null);
|
const panel3 = new TestPanel('id_2', null as any);
|
||||||
|
|
||||||
cut.openPanel(panel3, { skipSetPanelActive: true });
|
cut.openPanel(panel3, { skipSetPanelActive: true });
|
||||||
expect(contentContainer.length).toBe(1);
|
expect(contentContainer.length).toBe(1);
|
||||||
|
@ -27,7 +27,7 @@ const config: JestConfigWithTsJest = {
|
|||||||
'^.+\\.tsx?$': [
|
'^.+\\.tsx?$': [
|
||||||
'ts-jest',
|
'ts-jest',
|
||||||
{
|
{
|
||||||
tsconfig,
|
tsconfig: '<rootDir>/tsconfig.test.json',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
export function setMockRefElement(node: Partial<HTMLElement>): void {
|
export function setMockRefElement(node: Partial<HTMLElement>): void {
|
||||||
const mockRef = {
|
const mockRef = {
|
||||||
get current() {
|
get current() {
|
||||||
@ -10,5 +8,5 @@ export function setMockRefElement(node: Partial<HTMLElement>): void {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
jest.spyOn(React, 'useRef').mockReturnValueOnce(mockRef);
|
jest.spyOn(require('react'), 'useRef').mockReturnValueOnce(mockRef);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ describe('gridview react', () => {
|
|||||||
|
|
||||||
render(<DockviewReact components={components} onReady={onReady} />);
|
render(<DockviewReact components={components} onReady={onReady} />);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ describe('gridview react', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@ describe('gridview react', () => {
|
|||||||
|
|
||||||
render(<PaneviewReact components={components} onReady={onReady} />);
|
render(<PaneviewReact components={components} onReady={onReady} />);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ describe('react', () => {
|
|||||||
|
|
||||||
render(<TestWrapper onReady={onReady} component={Component} />);
|
render(<TestWrapper onReady={onReady} component={Component} />);
|
||||||
|
|
||||||
expect(api).toBeTruthy();
|
expect(api!).toBeTruthy();
|
||||||
|
|
||||||
expect(screen.getByTestId('valueA').textContent).toBe('stringA');
|
expect(screen.getByTestId('valueA').textContent).toBe('stringA');
|
||||||
expect(screen.getByTestId('valueB').textContent).toBe('42');
|
expect(screen.getByTestId('valueB').textContent).toBe('42');
|
||||||
@ -60,7 +60,7 @@ const TestWrapper = (props: {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const cut = new ReactPart<TestInterface>(
|
const cut = new ReactPart<TestInterface>(
|
||||||
ref.current,
|
ref.current!,
|
||||||
{
|
{
|
||||||
addPortal: (portal: React.ReactPortal) => {
|
addPortal: (portal: React.ReactPortal) => {
|
||||||
setPortal((_) => [..._, portal]);
|
setPortal((_) => [..._, portal]);
|
||||||
|
@ -47,7 +47,7 @@ describe('dockview', () => {
|
|||||||
|
|
||||||
render(<DockviewReact components={components} onReady={onReady} />);
|
render(<DockviewReact components={components} onReady={onReady} />);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -58,7 +58,7 @@ describe('gridview react', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@ describe('gridview react', () => {
|
|||||||
|
|
||||||
render(<PaneviewReact components={components} onReady={onReady} />);
|
render(<PaneviewReact components={components} onReady={onReady} />);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ describe('react', () => {
|
|||||||
|
|
||||||
render(<TestWrapper onReady={onReady} component={Component} />);
|
render(<TestWrapper onReady={onReady} component={Component} />);
|
||||||
|
|
||||||
expect(api).toBeTruthy();
|
expect(api!).toBeTruthy();
|
||||||
|
|
||||||
expect(screen.getByTestId('valueA').textContent).toBe('stringA');
|
expect(screen.getByTestId('valueA').textContent).toBe('stringA');
|
||||||
expect(screen.getByTestId('valueB').textContent).toBe('42');
|
expect(screen.getByTestId('valueB').textContent).toBe('42');
|
||||||
@ -60,7 +60,7 @@ const TestWrapper = (props: {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const cut = new ReactPart<TestInterface>(
|
const cut = new ReactPart<TestInterface>(
|
||||||
ref.current,
|
ref.current!,
|
||||||
{
|
{
|
||||||
addPortal: (portal: React.ReactPortal) => {
|
addPortal: (portal: React.ReactPortal) => {
|
||||||
setPortal((_) => [..._, portal]);
|
setPortal((_) => [..._, portal]);
|
||||||
|
@ -58,7 +58,7 @@ describe('splitview react', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -58,7 +58,7 @@ describe('splitview react', () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(api.width).toBe(650);
|
expect(api!.width).toBe(650);
|
||||||
expect(api.height).toBe(450);
|
expect(api!.height).toBe(450);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,5 +21,6 @@
|
|||||||
"ES2019",
|
"ES2019",
|
||||||
"DOM"
|
"DOM"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"exclude": ["**/*.spec.ts"]
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
"extends": "./tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
"jsx": "react-jsx"
|
||||||
"target": "es2019",
|
|
||||||
"sourceMap": true,
|
|
||||||
"declaration": true,
|
|
||||||
"jsx": "react",
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"allowUnreachableCode": false,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
// "strict": true,
|
|
||||||
"strictBindCallApply": true, // pass
|
|
||||||
"alwaysStrict": true, // pass
|
|
||||||
"noImplicitThis": true, // pass
|
|
||||||
"strictFunctionTypes": true, // pass
|
|
||||||
"strictNullChecks": false,
|
|
||||||
"strictPropertyInitialization": false,
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist"]
|
"include": ["**/*.spec.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user