Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
update README to reflect new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysforyou committed Nov 30, 2017
1 parent 2510eec commit 014f1e8
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DummyComponent title handleClick />;
Enzyme.configureEnzyme(Enzyme.react_16_adapter());
let header wrapper =>
wrapper
let setup = (~title="Test", ~handleClick=(_evt) => (), ()) =>
Enzyme.shallow(<DummyComponent title handleClick />);
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 = <h1>(ReasonReact.stringToElement title)</h1>;
expect (Enzyme.contains expectedNode wrapper) |> toBe true;
let wrapper = setup(~title, ());
let expectedNode = <h1> (ReasonReact.stringToElement(title)) </h1>;
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")
});
});
```
Expand Down

0 comments on commit 014f1e8

Please sign in to comment.