diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2016-05-09 11:20:26 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-05-09 11:20:26 -0700 |
commit | 288c01fc5f09a052918c3378a209063a44dab73e (patch) | |
tree | 7a199449418f9e85e44fa40495ffc49168d98f72 /actioncable/test/javascript/src/test_helpers | |
parent | 2399cfe23e40825229a498a81341beb85a077069 (diff) | |
parent | 71d406697266fc2525706361b86aeb85183fe4c7 (diff) | |
download | rails-288c01fc5f09a052918c3378a209063a44dab73e.tar.gz rails-288c01fc5f09a052918c3378a209063a44dab73e.tar.bz2 rails-288c01fc5f09a052918c3378a209063a44dab73e.zip |
Merge pull request #24935 from javan/actioncable-javascript-tests
WIP: Action Cable JavaScript tests
Diffstat (limited to 'actioncable/test/javascript/src/test_helpers')
-rw-r--r-- | actioncable/test/javascript/src/test_helpers/index.coffee | 5 | ||||
-rw-r--r-- | actioncable/test/javascript/src/test_helpers/mock_websocket.coffee | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/actioncable/test/javascript/src/test_helpers/index.coffee b/actioncable/test/javascript/src/test_helpers/index.coffee new file mode 100644 index 0000000000..e0d1e412cd --- /dev/null +++ b/actioncable/test/javascript/src/test_helpers/index.coffee @@ -0,0 +1,5 @@ +#= require_self +#= require_tree . + +ActionCable.TestHelpers = + testURL: "ws://cable.example.com/" diff --git a/actioncable/test/javascript/src/test_helpers/mock_websocket.coffee b/actioncable/test/javascript/src/test_helpers/mock_websocket.coffee new file mode 100644 index 0000000000..b7f86f18f6 --- /dev/null +++ b/actioncable/test/javascript/src/test_helpers/mock_websocket.coffee @@ -0,0 +1,21 @@ +#= require mock-socket + +NativeWebSocket = window.WebSocket + +server = null +consumer = null + +ActionCable.TestHelpers.createConsumer = (url, callback) -> + window.WebSocket = MockWebSocket + server = new MockServer url + consumer = ActionCable.createConsumer(url) + callback(consumer, server) + +QUnit.testDone -> + if consumer? + consumer.disconnect() + + if server? + server.clients().forEach (client) -> client.close() + server.close() + window.WebSocket = NativeWebSocket |