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 committed 2022-07-18 15:51:18 +03:00
1 parent da6eee05a6
commit 1797f910f2
3 files changed
+34

No files matched your search

+9
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: () => ({}),
};
@@ -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>
);
};
+8
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");