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