Created
June 11, 2017 13:53
-
-
Save brian-watkins/bbb655d34c70b370311dd18ecde61140 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 | |
import Elmer.Html as Markup | |
import Elmer.Html.Event as Event | |
import Elmer.Spy as Spy exposing (Spy, andCallFake) | |
import Elmer.Spy.Matchers exposing (wasCalledWith, stringArg) | |
import WebSocket | |
import App | |
webSocketSendSpy : Spy | |
webSocketSendSpy = | |
Spy.create "webSocketSend" (\_ -> WebSocket.send) | |
|> andCallFake (\_ _ -> Cmd.none) | |
sendTests : Test | |
sendTests = | |
describe "send message" | |
[ test "it says hello to the websocket" <| | |
\() -> | |
Elmer.given App.defaultModel App.view App.update | |
|> Spy.use [ webSocketSendSpy ] | |
|> Markup.target "#message-field" | |
|> Event.input "Hello!" | |
|> Markup.target "#send-button" | |
|> Event.click | |
|> Spy.expect "webSocketSend" ( | |
wasCalledWith | |
[ stringArg "ws://testserver.com" | |
, stringArg "Hello!" | |
] | |
) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment