[Pkg-javascript-commits] [sockjs-client] 07/22: #97 - simplify tests

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 78160f85492a59f3045060b354884818cbc4e2e8
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Sat Dec 29 04:13:09 2012 +0000

    #97 - simplify tests
---
 tests/html/src/tests.coffee     | 19 +++----------------
 tests/html/src/unittests.coffee | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index 7370210..90ef2db 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -8,26 +8,18 @@ protocols = ['websocket',
         'iframe-xhr-polling',
         'jsonp-polling']
 
-url_and_options = (path, protocol) ->
+newSockJS = (path, protocol) ->
     url = if /^http/.test(path) then path else client_opts.url + path
     options = jQuery.extend({}, client_opts.sockjs_opts)
     if protocol
         options.protocols_whitelist = [protocol]
-    [url, options]
-
-newSockJS = (path, protocol) ->
-    [url, options] = url_and_options(path, protocol)
     return new SockJS(url, null, options)
 
-cons_without_new = (path, protocol) ->
-    [url, options] = url_and_options(path, protocol)
-    return SockJS(url, null, options)
-
-echo_factory_factory = (protocol, messages, cons = newSockJS) ->
+echo_factory_factory = (protocol, messages) ->
     return ->
         expect(2 + messages.length)
         a = messages.slice(0)
-        r = cons('/echo', protocol)
+        r = newSockJS('/echo', protocol)
         r.onopen = (e) ->
             #log('onopen ' + e)
             ok(true)
@@ -55,10 +47,6 @@ echo_factory_factory = (protocol, messages, cons = newSockJS) ->
                 ok(true)
             start()
 
-factor_echo_without_new = (protocol) ->
-    messages = [ 'data' ]
-    return echo_factory_factory(protocol, messages, cons_without_new)
-
 factor_echo_basic = (protocol) ->
     messages = [ 'data' ]
     return echo_factory_factory(protocol, messages)
@@ -302,7 +290,6 @@ test_protocol_messages = (protocol) ->
         test "[disabled by config]", ->
                 log('Disabled by config: "' + protocol + '"')
     else
-        asyncTest("echo0", factor_echo_without_new(protocol))
         asyncTest("echo1", factor_echo_basic(protocol))
         asyncTest("echo2", factor_echo_rich(protocol))
         asyncTest("unicode", factor_echo_unicode(protocol))
diff --git a/tests/html/src/unittests.coffee b/tests/html/src/unittests.coffee
index b6487d1..53376ff 100644
--- a/tests/html/src/unittests.coffee
+++ b/tests/html/src/unittests.coffee
@@ -237,3 +237,24 @@ test "EventEmitter", ->
     r.removeEventListener 'close', single
     r.dispatchEvent({type:'close'}) # 0 runs
     r.close()
+
+
+instanceof_working = false
+try
+    obj = {}
+    instanceof_working = obj instanceof Object
+catch x
+    #pass
+
+if not instanceof_working
+    test "[NoConstructor unsupported by client]", ->
+        log('NoConstructor unsupported by client')
+else
+    test "NoConstructor", ->
+        expect(2)
+        r = new SockJS('//1.2.3.4/blah', null, {protocols_whitelist: []})
+        ok(r instanceof SockJS)
+        r.close()
+        r = SockJS('//1.2.3.4/blah', null, {protocols_whitelist: []})
+        ok(r instanceof SockJS)
+        r.close()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list