The sandbox module is helpful when developing components. It lets you
run the component using elm reactor outside the system and define several test cases.
A test case for the Component
Each test case contains a list of in-messages that will be sent to the component when the sandbox is started.
Wrap a component in a sandbox application.
This will render each test case and log all messages.
Create a test file with a main function where you declare all
test cases.
import Component.Form as Form
import Webbhuset.Component.Sandbox as Sandbox exposing (SandboxProgram)
main : SandboxProgram Form.Model Form.MsgIn
main =
Sandbox.ui
Form.component
"Form Component"
[ Sandbox.TestCase
"Empty form"
"Submit-button should be disabled"
[
]
, Sandbox.TestCase
"Form with Errors"
"You should see an error message"
[ Form.ErrorMsg "Error message"
]
]You can also use the ui sandbox on a Service component.
Just add a view function.
{ init = service.init
, update = service.update
, kill = service.kill
, subs = service.subs
, view = view
}
view : Model -> Html MsgIn
view model =
Html.text "Service Component"
The Program type of your main function.