File size: 804 Bytes
a7060a0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
  });
});