UNPKG

optimizely-oui

Version:

Optimizely's Component Library.

29 lines (28 loc) 1.31 kB
import React from "react"; import { render, shallow } from "enzyme"; import { Grid, GridCell, GridContainer } from "./grid"; describe("Grid", function () { it("renders correctly", function () { var grid = render(React.createElement(GridContainer, null, React.createElement(Grid, null, React.createElement(GridCell, null, React.createElement("p", null, "Content")), React.createElement(GridCell, null, React.createElement("p", null, "More content"))))); expect(grid).toMatchSnapshot(); }); describe("when given a className", function () { it("appends it to the root element", function () { var component = shallow(React.createElement(Grid, { className: "extra-class" }, "Text")); expect(component.prop("className").includes("extra-class")).toBe(true); }); }); describe("when given an unknown prop", function () { it("passes it to the root element", function () { // @ts-ignore: `unknownProps` is not part of any typed interface and therefore a good test value. var component = shallow(React.createElement(Grid, { unknownProp: "some value" }, "Text")); // @ts-ignore: toHaveProp exists from jest-enzyme, but TS isn't picking it up expect(component).toHaveProp({ unknownProp: "some value" }); }); }); });