lebel-studio / web /libs /ui /src /lib /code-editor /code-editor.spec.tsx
bisalsaha's picture
Upload 8831 files
a7060a0 verified
Raw History Blame Contribute Delete
804 Bytes
import { render } from "@testing-library/react";
import CodeEditor from "./code-editor";
// CodeMirror uses Range.prototype.getBoundingClientRect, which jsdom does not provide.
beforeAll(() => {
if (typeof Range !== "undefined" && !Range.prototype.getBoundingClientRect) {
Range.prototype.getBoundingClientRect = function () {
const rect = this.getClientRects?.();
if (rect?.[0]) return rect[0];
return {
x: 0,
y: 0,
width: 0,
height: 0,
top: 0,
right: 0,
bottom: 0,
left: 0,
toJSON: () => ({}),
} as DOMRect;
};
}
});
describe("CodeEditor", () => {
it("should render successfully", () => {
const { baseElement } = render(<CodeEditor />);
expect(baseElement).toBeTruthy();
});
});