Skip to content

Commit

Permalink
Add toBeEmptyDOMElement in favor of toBeEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 13, 2020
1 parent 688dbbc commit 456326f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/JestDom.re
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ let toBeEnabled = _toBeEnabled->pass;

let toBeEmpty = _toBeEmpty->pass;

[@bs.send.pipe: expect]
external _toBeEmptyDOMElement: unit = "toBeEmptyDOMElement";

let toBeEmptyDOMElement = _toBeEmptyDOMElement->pass;

[@bs.send.pipe: expect]
external _toBeInTheDocument: unit = "toBeInTheDocument";

Expand Down
1 change: 1 addition & 0 deletions src/JestDom.rei
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module TextContent: {
let toBeDisabled: expect => Jest.assertion;
let toBeEnabled: expect => Jest.assertion;
let toBeEmpty: expect => Jest.assertion;
let toBeEmptyDOMElement: expect => Jest.assertion;
let toBeInTheDocument: expect => Jest.assertion;
let toBeInvalid: expect => Jest.assertion;
let toBeRequired: expect => Jest.assertion;
Expand Down
15 changes: 15 additions & 0 deletions src/__tests__/JestDom_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ test("not toBeEmpty", () =>
|> toBeEmpty
);

test("toBeEmptyDOMElement", () =>
render({|<button data-testid="button"></button>|})
|> queryByTestId("button")
|> expect
|> toBeEmptyDOMElement
);

test("not toBeEmptyDOMElement", () =>
render({|<button disabled data-testid="button">Click me</button>|})
|> queryByTestId("button")
|> expect
|> not_
|> toBeEmptyDOMElement
);

test("toBeInTheDocument", () =>
render({|<button data-testid="button"></button>|})
|> queryByTestId("button")
Expand Down

0 comments on commit 456326f

Please sign in to comment.