Functions for the initial setup of a scenario.
Use the init function for a program created with Browser.application to set the
initial state for the scenario. You could do something like:
Spec.given (
Spec.Setup.initForApplication (App.init testFlags)
|> Spec.Setup.withDocument App.view
|> Spec.Setup.withUpdate App.update
)If your scenario involves location changes, you'll want to use this function in
conjunction with Spec.Setup.forNavigation to provide
those extra functions that an application requires. Providing these functions
is not necessary, but if you do not provde them, your spec will fail with an error
if it is setup with initForApplication and it tries to make location changes.
You can also use Spec.Setup.withLocation to set the URL that
will be passed to the application's init function at the start of the scenario.
So, a full setup for an application might look something like this:
Spec.given (
Spec.Setup.initForApplication (App.init testFlags)
|> Spec.Setup.withDocument App.view
|> Spec.Setup.withUpdate App.update
|> Spec.Setup.forNavigation
{ onUrlChange = App.urlDidChange
, onUrlRequest = App.urlChangeRequested
}
|> Spec.Setup.withLocation (someUrlWithPath "/sports")
)Provide an initial program model and command. The command will be executed as the first step in the scenario script.
You might use init in conjunction with the init function of the program whose
behavior the scenario describes. In that case you could do something like:
Spec.given (
Spec.Setup.init (App.init testFlags)
|> Spec.Setup.withUpdate App.update
|> Spec.Setup.withView App.view
)If you are describing the behavior of a program created with Browser.application then
consider using initForApplication instead.
Provide an initial model for the program whose behavior this scenario describes.
Set up the scenario to begin with a particular location.
If the program whose behavior is being described was created with Browser.application then
this Url will be provided to the init function. In any case, this location will serve as
the base href, and any location changes will be relative to this location.
By default, the scenario begins with the location http://elm-spec/
Provide the update function for the program whose behavior the scenario describes.
Provide the view function for the program whose behavior the scenario describes, where
this program is created with Browser.sandbox or Browser.element.
Provide the view function for the program whose behavior the scenario describes, where
this program is created with Browser.document or Browser.application.
Provide the subscriptions function for the program whose behavior the scenario describes.
Represents the initial state of the world for a scenario.