Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gameOverTests : Test
gameOverTests =
describe "when the game is over" <|
let
state =
Elmer.given App.defaultModel App.view (App.updateWith <| Spy.callable "fake-persist-score")
|> Elmer.Spy.Use [ persistScoreSpy ]
|> Elmer.Html.Events.click "#game-over-button"
in
[ test "it saves the score" <|
\() ->
state
|> Elmer.Spy.expect "fake-store-score" (wasCalledWith [ intArg 4 ])
, test "it displays the updated scores" <|
\() ->
state
|> Elmer.Html.target "#high-scores"
|> Elmer.Html.expect (element <|
hasText "4" <&&>
hasText "97" <&&>
hasText "101"
)
]
persistScoreSpy : Spy
persistScoreSpy =
Spy.createWith "fake-persist-score" (
\score ->
Command.fake <| App.scoresTagger [ score, 97, 101 ]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment