Skip to content

Instantly share code, notes, and snippets.

@brian-watkins
Created June 11, 2017 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brian-watkins/bbb655d34c70b370311dd18ecde61140 to your computer and use it in GitHub Desktop.
Save brian-watkins/bbb655d34c70b370311dd18ecde61140 to your computer and use it in GitHub Desktop.
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