Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTallJerry committed Feb 23, 2024
1 parent 354a79c commit 058b893
Show file tree
Hide file tree
Showing 5 changed files with 500 additions and 16 deletions.
6 changes: 3 additions & 3 deletions demo/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ const config: Config = {
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
transform: {
"^.+\\.(ts|tsx|js|jsx)$": "babel-jest",
},
// transform: {
// "^.+\\.(ts|tsx|js|jsx)$": "babel-jest",
// },

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
1 change: 1 addition & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"css-loader": "^6.8.1",
"html-webpack-plugin": "^5.6.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
"style-loader": "^3.3.3",
"typescript": "^5.3.3",
"webpack": "^5.89.0",
Expand Down
15 changes: 6 additions & 9 deletions demo/src/SvgDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ export default function SvgDisplay(props) {
}, [props.jsonResult]);

return (
<>
<canvas
data-testid="memory-models-canvas"
ref={canvasRef}
width={1000}
height={1000}
/>
;
</>
<canvas
data-testid="memory-models-canvas"
ref={canvasRef}
width={1000}
height={1000}
/>
);
}
8 changes: 4 additions & 4 deletions demo/src/__tests__/SvgDisplay.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { cleanup, render, screen } from "@testing-library/react";
import SvgDisplay from "../SvgDisplay";
import mem from "../../../src/index";
const { draw } = mem;
Expand Down Expand Up @@ -36,6 +36,8 @@ describe("SvgDisplay", () => {
render(<SvgDisplay jsonResult={jsonResult} />);
});

afterEach(cleanup);

it("renders canvas element with specified dimensions", () => {
const canvasElement = screen.getByTestId("memory-models-canvas");
expect(canvasElement.getAttribute("width")).toEqual("1000");
Expand All @@ -49,11 +51,9 @@ describe("SvgDisplay", () => {
});
});

it("does not render anything if jsonResult is null", () => {
it("does not render anything when jsonResult is null", () => {
render(<SvgDisplay jsonResult={null} />);
const canvasElement = screen.getByTestId("memory-models-canvas");
expect(canvasElement.getAttribute("ref")).toBeNull();
});

// Add more tests as needed
});
Loading

0 comments on commit 058b893

Please sign in to comment.