import React from "react";
import { render, shallow } from "enzyme";
import { Typography } from "./typography";
describe("Typography", () => {
it("renders header1 correctly", () => {
const component = render(Header 1);
expect(component).toMatchSnapshot();
});
it("renders header2 correctly", () => {
const component = render(Header 2);
expect(component).toMatchSnapshot();
});
it("renders header3 correctly", () => {
const component = render(Header 3);
expect(component).toMatchSnapshot();
});
it("renders header4 correctly", () => {
const component = render(Header 4);
expect(component).toMatchSnapshot();
});
it("renders header5 correctly", () => {
const component = render(Header 5);
expect(component).toMatchSnapshot();
});
it("renders subhead correctly", () => {
const component = render(Subhead);
expect(component).toMatchSnapshot();
});
it("renders body correctly", () => {
const component = render(Body);
expect(component).toMatchSnapshot();
});
it("renders caption correctly", () => {
const component = render(Caption);
expect(component).toMatchSnapshot();
});
it("renders xs correctly", () => {
const component = render(xs);
expect(component).toMatchSnapshot();
});
it("renders xxs correctly", () => {
const component = render(xxs);
expect(component).toMatchSnapshot();
});
describe("when given a className", () => {
it("appends it to the root element", () => {
const component = shallow(Body);
// @ts-ignore: toHaveProp exists from jest-enzyme, but TS isn't picking it up
expect(component).toHaveProp({ className: "axiom-typography--body extra-class" });
});
});
describe("when given an unknown prop", () => {
it("passes it to the root element", () => {
// @ts-ignore: `unknownProps` is not part of any typed interface and therefore a good test value.
const component = shallow(Body);
// @ts-ignore: toHaveProp exists from jest-enzyme, but TS isn't picking it up
expect(component).toHaveProp({ unknownProp: "some value" });
});
});
});