Created
April 15, 2018 17:05
-
-
Save brian-watkins/55ac2f396bc5a9ea67aff2f120a4b01d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
persistScoresTests : Test | |
persistScoresTests = | |
describe "when a score is persisted" <| | |
let | |
testState = | |
Headless.givenCommand (\_ -> LocalStoragePersistScore.execute <| 217) | |
|> Spy.use [ saveScoreSpy, getScoresSpy ] | |
|> Subscription.with (\() -> (\_ -> LocalStoragePersistScore.subscriptions ScoreTagger)) | |
|> Subscription.send "scores-sub" [ 190, 217, 218, 332 ] | |
in | |
[ test "it requests the scores" <| | |
\() -> | |
testState | |
|> Spy.expect "save-score-spy" ( | |
wasCalledWith [ intArg 217 ] | |
) | |
, test "it sends the recorded scores" <| | |
\() -> | |
testState | |
|> Headless.expectMessages (exactly 1 <| | |
Expect.equal (ScoreTagger [ 190, 217, 218, 332 ]) | |
) | |
] | |
type TestMsg | |
= ScoreTagger (List Score) | |
saveScoreSpy : Spy | |
saveScoreSpy = | |
Spy.create "save-score-spy" (\_ -> ScoreStore.saveScore) | |
|> andCallFake (\_ -> | |
Cmd.none | |
) | |
getScoresSpy : Spy | |
getScoresSpy = | |
Spy.create "scores-spy" (\_ -> ScoreStore.scores) | |
|> andCallFake (\tagger -> | |
Subscription.fake "scores-sub" tagger | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment