import React, { ReactElement } from "react"; import { render as renderer, RenderOptions } from "@testing-library/react"; import Grid from "../Grid"; import GridCell from "../GridCell"; import AppSizeListener from "../../sizing/AppSizeListener"; const render = ( children: ReactElement, options?: Omit ) => renderer(children, { ...options, wrapper: ({ children }) => {children}, }); describe("Grid", () => { it("should render correctly with the GridCell component", () => { const { container } = render( Cell 1 Cell 2 Cell 3 ); expect(container).toMatchSnapshot(); }); it("should inline the padding style unless it is 0 ", () => { const props = { "data-testid": "grid" }; const { getByTestId, rerender } = render(); const grid = getByTestId("grid"); expect(grid.style.padding).toBe("12px"); rerender(); expect(grid.style.padding).toBe(""); }); it("should render correctly when the columns props are provided", () => { // really need to make a way for this test to be changed since it relies on the AppSizeListener // for the current column size const { container, rerender } = render(); expect(container).toMatchSnapshot(); rerender( ); expect(container).toMatchSnapshot(); }); });