[Pkg-javascript-commits] [node-async] 68/480: updated nodeunit deps

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:13 UTC 2014


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

js pushed a commit to branch master
in repository node-async.

commit cb1825c7e64eb83011fced190386f4bc660570d7
Author: Caolan McMahon <caolan at caolanmcmahon.com>
Date:   Sun Dec 19 16:34:57 2010 +0000

    updated nodeunit deps
---
 deps/nodeunit.css  |  70 ++++++++++++++++++++++++
 deps/nodeunit.js   | 158 ++++++++++++++++++++++++++++-------------------------
 dist/async.min.js  |   2 +-
 test/test-async.js |  14 ++---
 test/test.html     |   4 +-
 5 files changed, 162 insertions(+), 86 deletions(-)

diff --git a/deps/nodeunit.css b/deps/nodeunit.css
new file mode 100644
index 0000000..274434a
--- /dev/null
+++ b/deps/nodeunit.css
@@ -0,0 +1,70 @@
+/*!
+ * Styles taken from qunit.css
+ */
+
+h1#nodeunit-header, h1.nodeunit-header {
+    padding: 15px;
+    font-size: large;
+    background-color: #06b;
+    color: white;
+    font-family: 'trebuchet ms', verdana, arial;
+    margin: 0;
+}
+
+h1#nodeunit-header a {
+    color: white;
+}
+
+h2#nodeunit-banner {
+    height: 2em;
+    border-bottom: 1px solid white;
+    background-color: #eee;
+    margin: 0;
+    font-family: 'trebuchet ms', verdana, arial;
+}
+h2#nodeunit-banner.pass {
+    background-color: green;
+}
+h2#nodeunit-banner.fail {
+    background-color: red;
+}
+
+h2#nodeunit-userAgent, h2.nodeunit-userAgent {
+    padding: 10px;
+    background-color: #eee;
+    color: black;
+    margin: 0;
+    font-size: small;
+    font-weight: normal;
+    font-family: 'trebuchet ms', verdana, arial;
+    font-size: 10pt;
+}
+
+div#nodeunit-testrunner-toolbar {
+    background: #eee;
+    border-top: 1px solid black;
+    padding: 10px;
+    font-family: 'trebuchet ms', verdana, arial;
+    margin: 0;
+    font-size: 10pt;
+}
+
+ol#nodeunit-tests {
+    font-family: 'trebuchet ms', verdana, arial;
+    font-size: 10pt;
+}
+ol#nodeunit-tests li strong {
+    cursor:pointer;
+}
+ol#nodeunit-tests .pass {
+    color: green;
+} 
+ol#nodeunit-tests .fail {
+    color: red;
+} 
+
+p#nodeunit-testresult {
+    margin-left: 1em;
+    font-size: 10pt;
+    font-family: 'trebuchet ms', verdana, arial;
+}
diff --git a/deps/nodeunit.js b/deps/nodeunit.js
index a4ae88c..5957184 100644
--- a/deps/nodeunit.js
+++ b/deps/nodeunit.js
@@ -1475,6 +1475,9 @@ exports.assertionList = function (arr, duration) {
         }
         return failures;
     };
+    that.passes = function () {
+        return that.length - that.failures();
+    };
     that.duration = duration || 0;
     return that;
 };
@@ -1521,9 +1524,11 @@ exports.test = function (name, start, options, callback) {
 
     var wrapAssert = assertWrapper(function (a) {
         a_list.push(a);
-        async.nextTick(function () {
-            options.log(a);
-        });
+        if (options.log) {
+            async.nextTick(function () {
+                options.log(a);
+            });
+        }
     });
 
     var test = {
@@ -1535,16 +1540,20 @@ exports.test = function (name, start, options, callback) {
                 );
                 var a1 = exports.assertion({method: 'expect', error: e});
                 a_list.push(a1);
-                async.nextTick(function () {
-                    options.log(a1);
-                });
+                if (options.log) {
+                    async.nextTick(function () {
+                        options.log(a1);
+                    });
+                }
             }
             if (err) {
                 var a2 = exports.assertion({error: err});
                 a_list.push(a2);
-                async.nextTick(function () {
-                    options.log(a2);
-                });
+                if (options.log) {
+                    async.nextTick(function () {
+                        options.log(a2);
+                    });
+                }
             }
             var end = new Date().getTime();
             async.nextTick(function () {
@@ -1588,7 +1597,7 @@ exports.options = function (opt) {
     optionalCallback('moduleDone');
     optionalCallback('testStart');
     optionalCallback('testDone');
-    optionalCallback('log');
+    //optionalCallback('log');
 
     // 'done' callback is not optional.
 
@@ -1855,30 +1864,6 @@ exports.testCase = function (suite) {
 exports.info = "Browser-based test reporter";
 
 
-exports.addStyles = function () {
-    document.body.innerHTML += '<style type="text/css">' +
-        'body { font: 12px Helvetica Neue }' +
-        'h2 { margin:0 ; padding:0 }' +
-        'pre {' +
-            'font: 11px Andale Mono;' +
-            'margin-left: 1em;' +
-            'padding-left: 1em;' +
-            'margin-top: 0;' +
-            'font-size:smaller;' +
-        '}' +
-        '.assertion_message { margin-left: 1em; }' +
-        '  ol {' +
-            'list-style: none;' +
-            'margin-left: 1em;' +
-            'padding-left: 1em;' +
-            'text-indent: -1em;' +
-        '}' +
-        '  ol li.pass:before { content: "\\2714 \\0020"; }' +
-        '  ol li.fail:before { content: "\\2716 \\0020"; }' +
-    '</style>';
-};
-
-
 /**
  * Run all tests within each module, reporting the results
  *
@@ -1888,63 +1873,88 @@ exports.addStyles = function () {
 
 exports.run = function (modules, options) {
     var start = new Date().getTime();
-    exports.addStyles();
 
-    var results, module;
+    function setText(el, txt) {
+        if ('innerText' in el) {
+            el.innerText = txt;
+        }
+        else if ('textContent' in el){
+            el.textContent = txt;
+        }
+    }
+
+    function getOrCreate(tag, id) {
+        var el = document.getElementById(id);
+        if (!el) {
+            el = document.createElement(tag);
+            el.id = id;
+            document.body.appendChild(el);
+        }
+        return el;
+    };
+
+    var header = getOrCreate('h1', 'nodeunit-header');
+    var banner = getOrCreate('h2', 'nodeunit-banner');
+    var userAgent = getOrCreate('h2', 'nodeunit-userAgent');
+    var tests = getOrCreate('ol', 'nodeunit-tests');
+    var result = getOrCreate('p', 'nodeunit-testresult');
 
-    results = document.createElement('div');
-    results.id = 'results';
-    document.body.appendChild(results);
+    setText(userAgent, navigator.userAgent);
 
     nodeunit.runModules(modules, {
         moduleStart: function (name) {
-            var mheading = document.createElement('h2');
+            /*var mheading = document.createElement('h2');
             mheading.innerText = name;
             results.appendChild(mheading);
             module = document.createElement('ol');
-            results.appendChild(module);
+            results.appendChild(module);*/
         },
         testDone: function (name, assertions) {
             var test = document.createElement('li');
-            if (!assertions.failures()) {
-                test.className = 'pass';
-                test.innerText = name;
-            }
-            else {
-                test.className = 'fail';
-                var html = name;
-                for (var i=0; i<assertions.length; i++) {
-                    var a = assertions[i];
-                    if (a.failed()) {
-                        if (a.error instanceof assert.AssertionError && a.message) {
-                            html += '<div class="assertion_message">' +
-                                'Assertion Message: ' + a.message +
-                            '</div>';
-                        }
-                        html += '<pre>';
-                        html += a.error.stack || a.error;
-                        html += '</pre>';
-                    }
-                };
-                test.innerHTML = html;
+            var strong = document.createElement('strong');
+            strong.innerHTML = name + ' <b style="color: black;">(' +
+                '<b class="fail">' + assertions.failures() + '</b>, ' +
+                '<b class="pass">' + assertions.passes() + '</b>, ' +
+                assertions.length +
+            ')</b>';
+            test.className = assertions.failures() ? 'fail': 'pass';
+            test.appendChild(strong);
+
+            var aList = document.createElement('ol');
+            aList.style.display = 'none';
+            test.onclick = function () {
+                var d = aList.style.display;
+                aList.style.display = (d == 'none') ? 'block': 'none';
+            };
+            for (var i=0; i<assertions.length; i++) {
+                var li = document.createElement('li');
+                var a = assertions[i];
+                if (a.failed()) {
+                    li.innerHTML = (a.message || a.method || 'no message') +
+                        '<pre>' + (a.error.stack || a.error) + '</pre>';
+                    li.className = 'fail';
+                }
+                else {
+                    li.innerHTML = a.message || a.method || 'no message';
+                    li.className = 'pass';
+                }
+                aList.appendChild(li);
             }
-            module.appendChild(test);
+            test.appendChild(aList);
+            tests.appendChild(test);
         },
         done: function (assertions) {
             var end = new Date().getTime();
             var duration = end - start;
 
-            var summary = document.createElement('h3');
-            if (assertions.failures()) {
-                summary.innerText = 'FAILURES: '  + assertions.failures() +
-                    '/' + assertions.length + ' assertions failed (' +
-                    assertions.duration + 'ms)';
-            }
-            else {
-                summary.innerText = 'OK: ' + assertions.length +
-                    ' assertions (' + assertions.duration + 'ms)';
-            }
-            document.body.appendChild(summary);
+            var failures = assertions.failures();
+            banner.className = failures ? 'fail': 'pass';
+
+            result.innerHTML = 'Tests completed in ' + duration +
+                ' milliseconds.<br/><span class="passed">' +
+                assertions.passes() + '</span> assertions of ' +
+                '<span class="all">' + assertions.length + '<span> passed, ' +
+                assertions.failures() + ' failed.';
         }
     });
 };
diff --git a/dist/async.min.js b/dist/async.min.js
index b8d1fe7..a2547ff 100644
--- a/dist/async.min.js
+++ b/dist/async.min.js
@@ -1 +1 @@
-/*global setTimeout: false, console: false */(function(){var a={};var b=this,c=b.async;typeof module!=="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){b.async=c;return a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)};var e=function(a,b){if(a.map)return a.map(b);var c=[];d(a,function(a,d,e){c.push(b(a,d,e))});return c};var f=function(a,b,c){if(a.reduce)return a.reduce(b,c);d(a,function(a,d,e){c=b(c,a,d,e)});ret [...]
\ No newline at end of file
+/*global setTimeout: false, console: false */(function(){var a={};var b=this,c=b.async;typeof module!=="undefined"&&module.exports?module.exports=a:b.async=a,a.noConflict=function(){b.async=c;return a};var d=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c<a.length;c+=1)b(a[c],c,a)};var e=function(a,b){if(a.map)return a.map(b);var c=[];d(a,function(a,d,e){c.push(b(a,d,e))});return c};var f=function(a,b,c){if(a.reduce)return a.reduce(b,c);d(a,function(a,d,e){c=b(c,a,d,e)});ret [...]
\ No newline at end of file
diff --git a/test/test-async.js b/test/test-async.js
index a4d4f0b..7b41393 100644
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -894,21 +894,15 @@ exports['nextTick'] = function(test){
 };
 
 exports['nextTick in node'] = function(test){
-    test.expect(1);
-    var browser = false;
     if (typeof process === 'undefined') {
-        browser = true;
-        window.process = {};
+        // skip this test in the browser
+        return test.done();
     }
+    test.expect(1);
     var _nextTick = process.nextTick;
     process.nextTick = function(){
-        if (browser) {
-            window.process = undefined;
-        }
-        else {
-            process.nextTick = _nextTick;
-        }
         test.ok(true, 'process.nextTick called');
+        process.nextTick = _nextTick;
         test.done();
     };
     async.nextTick(function(){});
diff --git a/test/test.html b/test/test.html
index fb5399c..2450e2d 100644
--- a/test/test.html
+++ b/test/test.html
@@ -1,12 +1,13 @@
 <html>
   <head>
-    <title>Async.js tests</title>
+    <title>Async.js Test Suite</title>
     <!--
       async must be included after nodeunit because nodeunit already uses
       the async lib internally and will overwrite the version we want to test
     -->
     <script src="../deps/nodeunit.js"></script>
     <script src="../lib/async.js"></script>
+    <link rel="stylesheet" href="../deps/nodeunit.css" type="text/css" media="screen" />
     <script>
       var _async = this.async;
       this.require = function () { return _async; };
@@ -15,6 +16,7 @@
     <script src="test-async.js"></script>
   </head>
   <body>
+    <h1 id="nodeunit-header">Async.js Test Suite</h1>
     <script>
       nodeunit.run({'test-async': exports});
     </script>

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



More information about the Pkg-javascript-commits mailing list