Skip to content

Commit 147f6d4

Browse files
Merge pull request #50 from tryretool/bb/add-testing
Add testing framework
2 parents 73ffad6 + 253f788 commit 147f6d4

File tree

4 files changed

+1106
-12
lines changed

4 files changed

+1106
-12
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ You will also see any lint errors in the console.
6969
3. Navigate to `/dst` directory.
7070
4. Publish to npm with `npm publish`
7171

72+
## Testing
73+
74+
Tests exist in the `/src/__tests__` directory. Running `yarn test` will run the test suite.
75+
7276
## Support
7377

7478
Need help? Please report issues or requests to [email protected], through in app chat, or on https://community.retool.com/

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@
6868
"@babel/cli": "^7.19.3",
6969
"@babel/plugin-proposal-class-properties": "^7.18.6",
7070
"@babel/preset-react": "^7.18.6",
71-
"react-scripts": "^5.0.1",
71+
"@testing-library/react": "^13.4.0",
72+
"jest": "^29.4.1",
7273
"react": "^18.2.0",
73-
"react-dom": "^18.2.0"
74+
"react-dom": "^18.2.0",
75+
"react-scripts": "^5.0.1"
7476
}
7577
}

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, screen } from "@testing-library/react";
3+
import Retool from "../components/Retool";
4+
5+
describe("react-retool", () => {
6+
it("has the correct src attribute", () => {
7+
render(
8+
<Retool url="https://support.retool.com/embedded/public/cb9e15f0-5d7c-43a7-a746-cdec870dde9a" />
9+
);
10+
11+
const iframe = screen.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+
render(<Retool height="100%" />);
19+
20+
const iframe = screen.getByTitle("retool");
21+
expect(iframe.height).toBe("100%");
22+
});
23+
24+
it("has the correct width attribute", () => {
25+
render(<Retool width="500px" />);
26+
27+
const iframe = screen.getByTitle("retool");
28+
expect(iframe.width).toBe("500px");
29+
});
30+
31+
it("has the correct sandbox attribute", () => {
32+
render(<Retool sandbox="allow-popups" />);
33+
34+
const iframe = screen.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+
render(<Retool allow="fullscreen" />);
42+
43+
const iframe = screen.getByTitle("retool");
44+
expect(iframe.getAttribute("allow")).toBe("fullscreen");
45+
});
46+
});

0 commit comments

Comments
 (0)