mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-24 22:21:45 +03:00
46 lines
1.2 KiB
Elm
46 lines
1.2 KiB
Elm
module TestApp exposing (app)
|
|
|
|
import App exposing (..)
|
|
import ProgramTest exposing (SimulatedEffect, createApplication)
|
|
import Routes
|
|
import SimulatedEffect.Cmd
|
|
import SimulatedEffect.Navigation
|
|
import Url
|
|
|
|
|
|
app route =
|
|
createApplication
|
|
{ init = init
|
|
, view = view
|
|
, update = update
|
|
, onUrlRequest = OnUrlRequest
|
|
, onUrlChange = OnUrlChange
|
|
}
|
|
|> ProgramTest.withBaseUrl ("https://styleguide.test/" ++ Routes.toString route)
|
|
|> ProgramTest.withSimulatedEffects simulateEffect
|
|
|> ProgramTest.start ()
|
|
|
|
|
|
simulateEffect : Effect -> SimulatedEffect Msg
|
|
simulateEffect effect =
|
|
case effect of
|
|
GoToRoute route ->
|
|
SimulatedEffect.Navigation.pushUrl (Routes.toString route)
|
|
|
|
GoToUrl url ->
|
|
SimulatedEffect.Navigation.pushUrl (Url.toString url)
|
|
|
|
Load loc ->
|
|
SimulatedEffect.Navigation.load loc
|
|
|
|
FocusOn id ->
|
|
-- TODO: mock an implementation
|
|
SimulatedEffect.Cmd.none
|
|
|
|
None ->
|
|
SimulatedEffect.Cmd.none
|
|
|
|
Command cmd ->
|
|
-- TODO: mock an implementation
|
|
SimulatedEffect.Cmd.none
|