mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add mocks for monaco editor and virtualized auto sizer to allow components to be rendered in unit tests
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
da6eee05a6
commit
1797f910f2
@ -3,3 +3,12 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
export default {};
|
export default {};
|
||||||
|
|
||||||
|
export const Uri = {
|
||||||
|
file: (path: string) => path,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const editor = {
|
||||||
|
getModel: () => ({}),
|
||||||
|
create: () => ({}),
|
||||||
|
};
|
||||||
|
|||||||
17
__mocks__/react-virtualized-auto-sizer.tsx
Normal file
17
__mocks__/react-virtualized-auto-sizer.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import React from "react";
|
||||||
|
import type { Size } from "react-virtualized-auto-sizer";
|
||||||
|
|
||||||
|
export default ({ children } : { children: (size: Size) => React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{children({
|
||||||
|
height: 420000,
|
||||||
|
width: 100,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -36,3 +36,11 @@ process.on("unhandledRejection", (err: any) => {
|
|||||||
|
|
||||||
global.TextEncoder = TextEncoder;
|
global.TextEncoder = TextEncoder;
|
||||||
global.TextDecoder = TextDecoderNode as unknown as typeof TextDecoder;
|
global.TextDecoder = TextDecoderNode as unknown as typeof TextDecoder;
|
||||||
|
|
||||||
|
global.ResizeObserver = class {
|
||||||
|
observe = () => {};
|
||||||
|
unobserve = () => {};
|
||||||
|
disconnect = () => {};
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.mock("./renderer/components/monaco-editor/monaco-editor");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user