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
Animesh Kumar
authored and
Fil Maj
committed
Mar 7, 2011
1 parent
e306ae0
commit 1d1acd3
Showing
1 changed file
with
62 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Tests.prototype.WebSocketTests = function() { | ||
module('WebSocket model'); | ||
test("should be able to define a WebSocket object", function() { | ||
expect(1); | ||
try { | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(websocket != null, "new WebSocket('valid-url') should not be null."); | ||
websocket.close(); | ||
} catch (e) { | ||
} | ||
}); | ||
test("should throw errors if 'url is invalid'", function() { | ||
expect(1); | ||
try { | ||
var websocket = new WebSocket('--invalid--'); | ||
} catch (e) { | ||
ok(e != null, "new WebSocket('valid-url') should throw error."); | ||
} | ||
}); | ||
test("should contain a 'send' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.send != 'undefined' && websocket.send != null, "websocket.send should not be null."); | ||
ok(typeof websocket.send == 'function', "websocket.send should be a function."); | ||
websocket.close(); | ||
}); | ||
test("should contain a 'close' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.close != 'undefined' && websocket.close != null, "websocket.close should not be null."); | ||
ok(typeof websocket.close == 'function', "websocket.close should be a function."); | ||
websocket.close(); | ||
}); | ||
test("should contain a 'onopen' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.onopen != 'undefined' && websocket.onopen != null, "websocket.onopen should not be null."); | ||
ok(typeof websocket.onopen == 'function', "websocket.onopen should be a function."); | ||
websocket.close(); | ||
}); | ||
test("should contain a 'onclose' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.onclose != 'undefined' && websocket.onclose != null, "websocket.onclose should not be null."); | ||
ok(typeof websocket.onclose == 'function', "websocket.onclose should be a function."); | ||
websocket.close(); | ||
}); | ||
test("should contain a 'onerror' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.onerror != 'undefined' && websocket.onerror != null, "websocket.onerror should not be null."); | ||
ok(typeof websocket.onerror == 'function', "websocket.onerror should be a function."); | ||
websocket.close(); | ||
}); | ||
test("should contain a 'onmessage' function", function() { | ||
expect(2); | ||
var websocket = new WebSocket('ws://localhost/'); | ||
ok(typeof websocket.onmessage != 'undefined' && websocket.onmessage != null, "websocket.onmessage should not be null."); | ||
ok(typeof websocket.onmessage == 'function', "websocket.onmessage should be a function."); | ||
websocket.close(); | ||
}); | ||
}; |