Skip to content

Commit d43630b

Browse files
committed
add intial testing framework
1 parent 379930b commit d43630b

File tree

3 files changed

+1102
-12
lines changed

3 files changed

+1102
-12
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262
"@babel/cli": "^7.19.3",
6363
"@babel/plugin-proposal-class-properties": "^7.18.6",
6464
"@babel/preset-react": "^7.18.6",
65-
"react-scripts": "^5.0.1",
65+
"@testing-library/react": "^13.4.0",
66+
"jest": "^29.4.1",
6667
"react": "^18.2.0",
67-
"react-dom": "^18.2.0"
68+
"react-dom": "^18.2.0",
69+
"react-scripts": "^5.0.1"
6870
}
6971
}

src/__tests__/retool.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
import { render } from "@testing-library/react";
3+
import Retool from "../components/Retool";
4+
5+
describe("react-retool", () => {
6+
it("has the correct src attribute", () => {
7+
const { getByTitle } = render(
8+
<Retool url="https://support.retool.com/embedded/public/cb9e15f0-5d7c-43a7-a746-cdec870dde9a" />
9+
);
10+
// eslint-disable-next-line testing-library/prefer-screen-queries
11+
const iframe = getByTitle("retool");
12+
expect(iframe.src).toBe(
13+
"https://support.retool.com/embedded/public/cb9e15f0-5d7c-43a7-a746-cdec870dde9a"
14+
);
15+
});
16+
17+
it("has the correct height attribute", () => {
18+
const { getByTitle } = render(<Retool height="100%" />);
19+
// eslint-disable-next-line testing-library/prefer-screen-queries
20+
const iframe = getByTitle("retool");
21+
expect(iframe.height).toBe("100%");
22+
});
23+
24+
it("has the correct width attribute", () => {
25+
const { getByTitle } = render(<Retool width="500px" />);
26+
// eslint-disable-next-line testing-library/prefer-screen-queries
27+
const iframe = getByTitle("retool");
28+
expect(iframe.width).toBe("500px");
29+
});
30+
31+
it("has the correct sandbox attribute", () => {
32+
const { getByTitle } = render(<Retool sandbox="allow-popups" />);
33+
// eslint-disable-next-line testing-library/prefer-screen-queries
34+
const iframe = getByTitle("retool");
35+
expect(iframe.getAttribute("sandbox")).toBe(
36+
"allow-scripts allow-same-origin allow-popups"
37+
);
38+
});
39+
40+
it("has the correct allow attribute", () => {
41+
const { getByTitle } = render(<Retool allow="fullscreen" />);
42+
// eslint-disable-next-line testing-library/prefer-screen-queries
43+
const iframe = getByTitle("retool");
44+
expect(iframe.getAttribute("allow")).toBe("fullscreen");
45+
});
46+
});

0 commit comments

Comments
 (0)