|
| 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