diff --git a/src/components/Markdown.js b/src/components/Markdown.js index e223320..cac1526 100644 --- a/src/components/Markdown.js +++ b/src/components/Markdown.js @@ -116,6 +116,7 @@ LinkRenderer.defaultProps = { /** Markdown component */ +// note: Markdown component only transfers className as remaining props (not style or others) const Markdown = ({ repository, source, ...remainingProps }) => ( ({ } }); +// note: Markdown component only transfers className as remaining props (not style or others) - so does Readme const Readme = ({ classes, source, diff --git a/src/components/__tests__/CodeBlock.spec.js b/src/components/__tests__/CodeBlock.spec.js index c30d838..e234744 100644 --- a/src/components/__tests__/CodeBlock.spec.js +++ b/src/components/__tests__/CodeBlock.spec.js @@ -20,11 +20,17 @@ describe("/components/CodeBlock", () => { "Hello world" ); }); + it("should pass value as child", () => { + const { getByText } = render( + + ); + expect(getByText("some code")).toBeTruthy(); + }); it("should set className on element according to props.language", () => { - const { container } = render(); - const [codeElement] = container.getElementsByClassName("language-js"); - expect(codeElement).toBeTruthy(); + const { getByText } = render( + + ); + expect(getByText("some code")).toHaveClass("language-js"); }); - // @todo test markdown formatting }); }); diff --git a/src/components/__tests__/Markdown.spec.js b/src/components/__tests__/Markdown.spec.js new file mode 100644 index 0000000..f9d9a0a --- /dev/null +++ b/src/components/__tests__/Markdown.spec.js @@ -0,0 +1,23 @@ +import React from "react"; +import { render } from "../../testUtils"; + +import Markdown from "../Markdown"; + +describe("/components/Markdown", () => { + describe("render", () => { + it("should ONLY pass className from remainingProps", () => { + const { container } = render( + + ); + expect(container.firstChild).toHaveClass("hello-world"); + expect(container.firstChild.style.color).not.toBe("red"); + expect(container.firstChild.getAttribute("data-infos")).not.toBe( + "Hello world" + ); + }); + }); +});