This module allows you to simulate events on Html nodes, the Msg generated by the event is returned so you can test it
Simulates an event on a node
type Msg
= Change String
test "Input produces expected Msg" <|
\() ->
Html.input [ onInput Change ] [ ]
|> Query.fromHtml
|> Events.simulate (Input "cats")
|> Expect.expectEvent (Change "cats")Passes if given event equals the triggered event
type Msg
= Change String
test "Input produces expected Msg" <|
\() ->
Html.input [ onInput Change ] [ ]
|> Query.fromHtml
|> Events.simulate (Input "cats")
|> Expect.expectEvent (Change "cats")Returns a Result with the Msg produced by the event simulated on a node
test "Input produces expected Msg" <| () -> Html.input [ onInput Change ] [ ] |> Query.fromHtml |> Events.simulate (Input "cats") |> Events.eventResult |> Expect.equal (Ok <| Change "cats")
Event constructors to simulate events