eeue56/elm-html-test/1.1.0

NOTE: this package is not compatible with Elm 0.19.1

Test.Html.Events

This module allows you to simulate events on Html nodes, the Msg generated by the event is returned so you can test it

type Event
= Click
| DoubleClick
| MouseDown
| MouseUp
| MouseEnter
| MouseLeave
| MouseOver
| MouseOut
| Input String
| Check Bool
| Submit
| Blur
| Focus
| CustomEvent String String

Event constructors to simulate events

simulate : Event -> Single -> EventNode

Gets a Msg produced by a node when an event is simulated.

type Msg
    = Change String


test "Input produces expected Msg" <|
    \() ->
        Html.input [ onInput Change ] [ ]
            |> Query.fromHtml
            |> Events.simulate (Input "cats")
            |> Expect.equal (Ok <| Change "cats")
expectEvent : msg -> EventNode -> Expectation

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.equal (Ok <| Change "cats")