1
0
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:
Janne Savolainen 2022-07-18 15:01:37 +03:00
parent da6eee05a6
commit 1797f910f2
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
3 changed files with 34 additions and 0 deletions

View File

@ -3,3 +3,12 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export default {};
export const Uri = {
file: (path: string) => path,
};
export const editor = {
getModel: () => ({}),
create: () => ({}),
};

View 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>
);
};

View File

@ -36,3 +36,11 @@ process.on("unhandledRejection", (err: any) => {
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoderNode as unknown as typeof TextDecoder;
global.ResizeObserver = class {
observe = () => {};
unobserve = () => {};
disconnect = () => {};
};
jest.mock("./renderer/components/monaco-editor/monaco-editor");