Skip to content

Commit

Permalink
Add toBePartiallyChecked matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Jun 13, 2020
1 parent 7bfdbbf commit 688dbbc
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 @@ -139,6 +139,11 @@ let toHaveDisplayValue = value => value->_toHaveDisplayValue->pass;

let toBeChecked = _toBeChecked->pass;

[@bs.send.pipe: expect]
external _toBePartiallyChecked: unit = "toBePartiallyChecked";

let toBePartiallyChecked = _toBePartiallyChecked->pass;

[@bs.send.pipe: expect]
external _toHaveDescription:
([@bs.unwrap] [ | `Str(string) | `RegExp(Js.Re.t)]) => unit =
Expand Down
1 change: 1 addition & 0 deletions src/JestDom.rei
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ let toHaveValue:
let toHaveDisplayValue:
([ | `Str(string) | `RegExp(Js.Re.t) | `Arr(array(string))], expect) => Jest.assertion;
let toBeChecked: expect => Jest.assertion;
let toBePartiallyChecked: expect => Jest.assertion;
let toHaveDescription:
([ | `Str(string) | `RegExp(Js.Re.t)], expect) => Jest.assertion;
15 changes: 15 additions & 0 deletions src/__tests__/JestDom_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,21 @@ test("not toBeChecked", () =>
|> toBeChecked
);

test("toBePartiallyChecked", () =>
render({|<input type="checkbox" aria-checked="mixed" data-testid="input" />|})
|> queryByTestId("input")
|> expect
|> toBePartiallyChecked
);

test("not toBePartiallyChecked", () =>
render({|<input type="checkbox" checked data-testid="input" />|})
|> queryByTestId("input")
|> expect
|> not_
|> toBePartiallyChecked
);

test("toHaveDescription (string)", () =>
render({|<span><button data-testid="button" aria-label="Close" aria-describedby="description-close">X</button><div id="description-close">Closing will discard any changes</div></span>|})
|> queryByTestId("button")
Expand Down

0 comments on commit 688dbbc

Please sign in to comment.