-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
|
||
heartbeat_test_factory = (protocol) -> | ||
module(protocol) | ||
if not SockJS[protocol] or not SockJS[protocol].enabled() | ||
test "[unsupported by client]", -> | ||
log('Unsupported protocol (by client): "' + protocol + '"') | ||
return | ||
if client_opts.disabled_transports and | ||
arrIndexOf(client_opts.disabled_transports, protocol) isnt -1 | ||
test "[disabled by config]", -> | ||
log('Disabled by config: "' + protocol + '"') | ||
return | ||
|
||
asyncTest 'single heartbeat', -> | ||
expect(3) | ||
r = newSockJS('/echo', protocol) | ||
r.onopen = (e) -> | ||
ok(true) | ||
r._sendHeartbeat() | ||
r.send('a') | ||
r.onmessage = (e) -> | ||
equal(e.data, 'a') | ||
r.close() | ||
r.onclose = (e) -> | ||
log(JSON.stringify(e)) | ||
ok(true) | ||
start() | ||
|
||
asyncTest 'round trip', -> | ||
expect(3) | ||
r = newSockJS('/heartbeat', protocol) | ||
r.onopen = (e) -> | ||
ok(true) | ||
r._sendHeartbeat() | ||
r.onmessage = (e) -> | ||
equal(e.data, 'heartbeat') | ||
r.close() | ||
r.onclose = () -> | ||
ok(true) | ||
start() | ||
|
||
asyncTest 'server heartbeat', -> | ||
expect(3) | ||
r = newSockJS('/heartbeat', protocol) | ||
r.onopen = (e) -> | ||
ok(true) | ||
r.onheartbeat = (e) -> | ||
ok(true) | ||
r.close() | ||
r.onclose = () -> | ||
ok(true) | ||
start() | ||
|
||
|
||
for protocol in protocols | ||
heartbeat_test_factory(protocol) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta charset="UTF-8" /> | ||
|
||
<script type="text/javascript" src="lib/sockjs.js"></script> | ||
|
||
<script type="text/javascript" src="static/jquery.min.js"></script> | ||
|
||
<link rel="stylesheet" href="static/qunit.css" type="text/css" media="screen"> | ||
<script type="text/javascript" src="static/qunit.min.js"></script> | ||
|
||
<script type="text/javascript" src="config.js"></script> | ||
<script type="text/javascript" src="lib/utils.js"></script> | ||
<script type="text/javascript" src="lib/heartbeattests.js"></script> | ||
</head> | ||
<body> | ||
<p> | ||
<h1 id="qunit-header">SockJS Heartbeat tests</h1> | ||
<h2 id="qunit-banner"></h2> | ||
<div id="qunit-testrunner-toolbar"></div> | ||
<h2 id="qunit-userAgent"></h2> | ||
<ol id="qunit-tests"></ol> | ||
<div id="qunit-fixture"></div> | ||
</p> | ||
<br> | ||
<code id="logs" style="height:200px; overflow:auto; display: block; border: 1px gray solid;"> | ||
</code> | ||
|
||
<script> | ||
function log(a, e) { | ||
if ('console' in window && 'log' in window.console) { | ||
console.log(a, e); | ||
} | ||
$('#logs').append($("<code>").text(a)); | ||
$('#logs').append($("<pre>").text(JSON.stringify(e, null, 4))); | ||
$('#logs').append($("<br>")); | ||
$('#logs').scrollTop($('#logs').scrollTop()+10000); | ||
} | ||
log('Running against: ' + client_opts.url); | ||
</script> | ||
</body> | ||
</html> |