forked from assaf/zombie
/
websocket-spec.coffee
51 lines (39 loc) · 1.1 KB
/
websocket-spec.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require "./helpers"
{ vows: vows, assert: assert, zombie: zombie, brains: brains } = require("vows")
jsdom = require("jsdom")
brains.get "/ws", (req, res)-> res.send """
<html>
<head>
<title>jQuery</title>
<script src="/jquery.js"></script>
</head>
<body>
<select>
<option>None</option>
<option value="1">One</option>
</select>
<span id="ws"></span>
<a href="#post">Post</a>
<div id="response"></div>
</body>
<script>
$(function() {
ws = new WebSocket('ws://localhost/some/url');
$('#ws').text(ws.url);
});
</script>
</html>
"""
brains.post "/echo", (req, res)->
lines = for key, value of req.body
key + "=" + value
res.send lines.join("\n")
vows.describe("Compatibility with WebSockets").addBatch(
"WebSockets":
zombie.wants "http://localhost:3003/ws"
"Creating a Websocket":
topic: (browser)->
browser.text "#ws"
@callback null, browser
"should be possible": (browser)-> assert.equal browser.text("#ws"), "ws://localhost/some/url"
).export(module)