Skip to content

Instantly share code, notes, and snippets.

@brian-watkins
Created April 15, 2018 16:49
Show Gist options
  • Save brian-watkins/1263b72831d71ed7ae44847aa4514b9f to your computer and use it in GitHub Desktop.
Save brian-watkins/1263b72831d71ed7ae44847aa4514b9f to your computer and use it in GitHub Desktop.
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