diff --git a/README.md b/README.md index 06d5f99..99d790d 100644 --- a/README.md +++ b/README.md @@ -20,48 +20,48 @@ Using the excellent [bs-jest](https://github.com/reasonml-community/bs-jest) ```reason open Jest; -let setup ::title="Test" ::handleClick=(fun _evt => ()) () => - Enzyme.shallow ; +Enzyme.configureEnzyme(Enzyme.react_16_adapter()); -let header wrapper => - wrapper +let setup = (~title="Test", ~handleClick=(_evt) => (), ()) => + Enzyme.shallow(); + +let header = (wrapper) => +wrapper |> Enzyme.find("#header") - |> Enzyme.first(); + |> Enzyme.first; -let listItems wrapper => +let listItems = (wrapper) => wrapper - |> Enzyme.find "#list" + |> Enzyme.find("#list") |> Enzyme.children; -describe "DummyComponent" (fun () => { +describe("DummyComponent", () => { open Expect; - test "renders a #header" (fun () => { + test("renders a #header", () => { let title = "A test title"; - let wrapper = setup title::title (); + let wrapper = setup(~title, ()); let headerNodes = wrapper |> header; - - expect (Enzyme.length headerNodes) |> toBe 1; + expect(Enzyme.length(headerNodes)) |> toBe(1) }); - test "has the expected h1 tag in the #header" (fun () => { + test("has the expected h1 tag in the #header", () => { let title = "A test title"; - let wrapper = setup title::title (); - let expectedNode =

(ReasonReact.stringToElement title)

; - - expect (Enzyme.contains expectedNode wrapper) |> toBe true; + let wrapper = setup(~title, ()); + let expectedNode =

(ReasonReact.stringToElement(title))

; + expect(Enzyme.contains(expectedNode, wrapper)) |> toBe(true) }); - test "initially has its `clicked` state set to false" (fun () => { - let wrapper = setup (); - let { clicked }: DummyComponent.state = Enzyme.state wrapper; - expect clicked |> toBe false; + test("initially has its `clicked` state set to false", () => { + let wrapper = setup(); + let {clicked}: DummyComponent.state = Enzyme.state(wrapper); + expect(clicked) |> toBe(false) }); - test "folds left properly" (fun () => { - let items = setup () |> listItems; - let result = Enzyme.foldLeft (fun text node => text ^ Enzyme.text node) "" items; - expect result |> toBe "OneTwoThree"; + test("folds left properly", () => { + let items = setup() |> listItems; + let result = Enzyme.foldLeft((text, node) => text ++ Enzyme.text(node), "", items); + expect(result) |> toBe("OneTwoThree") }); }); ```