import { render } from "@testing-library/react"; import { MemoryRouter } from "react-router-dom"; import "@testing-library/jest-dom"; import { VuiSearchResult } from "./SearchResult"; describe("VuiSearchResult", () => { describe("renders", () => { test("all props", () => { const { asFragment } = render( subTitle} className="customClass" snippetProps={{ className: "snippetCustomClass" }} >
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

title

subTitle

date — pre text

children
`); }); test("missing optional props", () => { const { asFragment } = render(
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

pre text

children
`); }); test("has title but missing url", () => { const { asFragment } = render(
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

title

pre text

children
`); }); test("missing title but has url", () => { const { asFragment } = render(
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

url

pre text

children
`); }); test("has empty title but has url", () => { const { asFragment } = render(
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

url

pre text

children
`); }); test("has empty title and empty url", () => { const { asFragment } = render(
children
, { wrapper: MemoryRouter } ); expect(asFragment()).toMatchInlineSnapshot(`
1

pre text

children
`); }); }); });