avh4/elm-testable/2.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 action model =
{ init : ( model, Effects action )
, update : action -> model -> ( model, Effects action )
}

A component that can be used to create a TestContext

type TestContext action model

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

startForTest : Component action model -> TestContext action model

Create a TestContext for the given Component

update : action -> TestContext action model -> TestContext action model

Apply an action to the component in a given TestContext

Inspecting

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

Get the current state of the component under test

assertCurrentModel : model -> TestContext action model -> Assertion

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

assertHttpRequest : Request -> TestContext action model -> Assertion

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

Simulating Effects

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

Simulate an HTTP response

advanceTime : Time -> TestContext action model -> TestContext action model

Simulate the passing of time