avh4/elm-testable/3.0.0

NOTE: this package is not compatible with Elm 0.19.1

Testable.TestContext

A TestContext allows you to manage the lifecycle of an Elm component that uses Testable.Effects. Using TestContext, you can write tests that exercise the entire lifecycle of your component.

type alias Component msg model =
{ init : ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
}

A component that can be used to create a TestContext

type TestContext msg model

The representation of the current state of a testable component, including a representaiton of any pending Effects.

startForTest : Component msg model -> TestContext msg model

Create a TestContext for the given Component

update : msg -> TestContext msg model -> TestContext msg model

Apply an msg to the component in a given TestContext

Inspecting

currentModel : TestContext msg model -> Result (List String) model

Get the current state of the component under test

assertCurrentModel : model -> TestContext msg model -> Assertion

A convenient way to assert about the current state of the component under test

assertHttpRequest : Request -> TestContext msg model -> Assertion

Assert that a given Http.Request has been made by the componet under test

assertNoPendingHttpRequests : TestContext msg model -> Assertion

Ensure that there are no pending HTTP requests

Simulating Effects

Request
-> Result RawError Response
-> TestContext msg model
-> TestContext msg model

Simulate an HTTP response

advanceTime : Time -> TestContext msg model -> TestContext msg model

Simulate the passing of time