Created
June 11, 2017 14:07
-
-
Save brian-watkins/cd243ba71dc29d94973d60f13cc3780d 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
module WebSocketTests exposing (..) | |
import Test exposing (..) | |
import Expect | |
import Elmer exposing (atIndex, (<&&>)) | |
import Elmer.Html as Markup | |
import Elmer.Html.Matchers exposing (elements, hasText) | |
import Elmer.Spy as Spy exposing (Spy, andCallFake) | |
import Elmer.Platform.Subscription as Subscription | |
import WebSocket | |
import App | |
webSocketListenSpy : Spy | |
webSocketListenSpy = | |
Spy.create "webSocketListen" (\_ -> WebSocket.listen) | |
|> andCallFake (\_ tagger -> | |
Subscription.fake "webSocket" tagger | |
) | |
listenTests : Test | |
listenTests = | |
describe "listen for message" | |
[ describe "when a list of items is received via the websocket" | |
[ test "it shows the items" <| | |
\() -> | |
Elmer.given App.defaultModel App.view App.update | |
|> Spy.use [ webSocketListenSpy ] | |
|> Subscription.with (\() -> App.subscriptions) | |
|> Subscription.send "webSocket" "[\"fun\",\"sun\",\"beach\"]" | |
|> Markup.target "#items li" | |
|> Markup.expect (elements <| | |
(atIndex 0 <| hasText "fun") <&&> | |
(atIndex 1 <| hasText "sun") <&&> | |
(atIndex 2 <| hasText "beach") | |
) | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment