github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
    • 1,144
    • 287
  • Source
  • Commits
  • Network (287)
  • Graphs
  • Tree: dffcba0

click here to add a description

click here to add a homepage

  • Switch Branches (8)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
    • widget-super
  • Switch Tags (22)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.5
    • 1.8.4
    • 1.8.3
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…
Downloads

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Update to latest QUnit.
jzaefferer (author)
Fri Jul 30 05:39:54 -0700 2010
commit  dffcba0ba6d77413f700
tree    605750babc0a428f624f
parent  ea58cd5ac0d852a9c7d7

Showing 3 changed files with 495 additions and 270 deletions.

M external/qunit.css 233 ••••
M external/qunit.js 526 ••••
M tests/unit/slider/slider_events.js 6 ••••
Txt external/qunit.css
  • View file @ dffcba0
... ...
@@ -1,119 +1,148 @@
  1
+/** Font Family and Sizes */
1 2
 
2  
-ol#qunit-tests {
3  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
4  
-  margin:0;
5  
-  padding:0;
6  
-  list-style-position:inside;
7  
-
8  
-  font-size: smaller;
  3
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
  4
+  font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
9 5
 }
10  
-ol#qunit-tests li{
11  
-  padding:0.4em 0.5em 0.4em 2.5em;
12  
-  border-bottom:1px solid #fff;
13  
-  font-size:small;
14  
-  list-style-position:inside;
  6
+
  7
+#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
  8
+#qunit-tests { font-size: smaller; }
  9
+
  10
+
  11
+/** Resets */
  12
+
  13
+#qunit-tests, #qunit-tests li ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
  14
+  margin: 0;
  15
+  padding: 0;
15 16
 }
16  
-ol#qunit-tests li ol{
17  
-  box-shadow: inset 0px 2px 13px #999;
18  
-  -moz-box-shadow: inset 0px 2px 13px #999;
19  
-  -webkit-box-shadow: inset 0px 2px 13px #999;
20  
-  margin-top:0.5em;
21  
-  margin-left:0;
22  
-  padding:0.5em;
23  
-  background-color:#fff;
24  
-  border-radius:15px;
25  
-  -moz-border-radius: 15px;
26  
-  -webkit-border-radius: 15px;
  17
+
  18
+
  19
+/** Header */
  20
+
  21
+#qunit-header {
  22
+  padding: 0.5em 0 0.5em 1em;
  23
+  
  24
+  color: #fff;
  25
+  text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
  26
+  background-color: #0d3349;
  27
+  
  28
+  border-radius: 15px 15px 0 0;
  29
+  -moz-border-radius: 15px 15px 0 0;
  30
+  -webkit-border-top-right-radius: 15px;
  31
+  -webkit-border-top-left-radius: 15px;
27 32
 }
28  
-ol#qunit-tests li li{
29  
-  border-bottom:none;
30  
-  margin:0.5em;
31  
-  background-color:#fff;
32  
-  list-style-position: inside;
33  
-  padding:0.4em 0.5em 0.4em 0.5em;
  33
+
  34
+#qunit-banner {
  35
+  height: 5px;
34 36
 }
35 37
 
36  
-ol#qunit-tests li li.pass{
37  
-  border-left:26px solid #C6E746;
38  
-  background-color:#fff;
39  
-  color:#5E740B;
40  
-  }
41  
-ol#qunit-tests li li.fail{
42  
-  border-left:26px solid #EE5757;
43  
-  background-color:#fff;
44  
-  color:#710909;
  38
+#qunit-testrunner-toolbar {
  39
+  padding: 0em 0 0.5em 2em;
45 40
 }
46  
-ol#qunit-tests li.pass{
47  
-  background-color:#D2E0E6;
48  
-  color:#528CE0;
  41
+
  42
+#qunit-userAgent {
  43
+  padding: 0.5em 0 0.5em 2.5em;
  44
+  background-color: #2b81af;
  45
+  color: #fff;
  46
+  text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
49 47
 }
50  
-ol#qunit-tests li.fail{
51  
-  background-color:#EE5757;
52  
-  color:#000;
  48
+
  49
+
  50
+/** Tests: Pass/Fail */
  51
+
  52
+#qunit-tests {
  53
+  list-style-position: inside;
53 54
 }
54  
-ol#qunit-tests li strong {
55  
-  cursor:pointer;
  55
+
  56
+#qunit-tests li {
  57
+  padding: 0.4em 0.5em 0.4em 2.5em;
  58
+  border-bottom: 1px solid #fff;
  59
+  list-style-position: inside;
56 60
 }
57  
-h1#qunit-header{
58  
-  background-color:#0d3349;
59  
-  margin:0;
60  
-  padding:0.5em 0 0.5em 1em;
61  
-  color:#fff;
62  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
63  
-  border-top-right-radius:15px;
64  
-  border-top-left-radius:15px;
65  
-  -moz-border-radius-topright:15px;
66  
-  -moz-border-radius-topleft:15px;
67  
-  -webkit-border-top-right-radius:15px;
68  
-  -webkit-border-top-left-radius:15px;
69  
-  text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
  61
+
  62
+#qunit-tests li strong {
  63
+  cursor: pointer;
70 64
 }
71  
-h2#qunit-banner{
72  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
73  
-  height:5px;
74  
-  margin:0;
75  
-  padding:0;
  65
+
  66
+#qunit-tests li ol {
  67
+  margin-top: 0.5em;
  68
+  padding: 0.5em;
  69
+  
  70
+  background-color: #fff;
  71
+  
  72
+  border-radius: 15px;
  73
+  -moz-border-radius: 15px;
  74
+  -webkit-border-radius: 15px;
  75
+  
  76
+  box-shadow: inset 0px 2px 13px #999;
  77
+  -moz-box-shadow: inset 0px 2px 13px #999;
  78
+  -webkit-box-shadow: inset 0px 2px 13px #999;
76 79
 }
77  
-h2#qunit-banner.qunit-pass{
78  
-  background-color:#C6E746;
  80
+
  81
+#qunit-tests li li {
  82
+  margin: 0.5em;
  83
+  padding: 0.4em 0.5em 0.4em 0.5em;
  84
+  background-color: #fff;
  85
+  border-bottom: none;
  86
+  list-style-position: inside;
79 87
 }
80  
-h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
81  
-  background-color:#EE5757;
  88
+
  89
+/*** Passing Styles */
  90
+
  91
+#qunit-tests li li.pass {
  92
+  color: #5E740B;
  93
+  background-color: #fff;
  94
+  border-left: 26px solid #C6E746;
82 95
 }
83  
-#qunit-testrunner-toolbar {
84  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
85  
-  padding:0;
86  
-  /*width:80%;*/
87  
-  padding:0em 0 0.5em 2em;
88  
-  font-size: small;
  96
+
  97
+#qunit-tests li.pass                        { color: #528CE0; background-color: #D2E0E6; }
  98
+#qunit-tests li.pass span.test-name         { color: #366097; }
  99
+ 
  100
+#qunit-tests li li.pass span.test-actual,
  101
+#qunit-tests li li.pass span.test-expected  { color: #999999; }
  102
+
  103
+strong b.pass                               { color: #5E740B; }
  104
+
  105
+#qunit-banner.qunit-pass                    { background-color: #C6E746; }
  106
+
  107
+/*** Failing Styles */
  108
+
  109
+#qunit-tests li li.fail {
  110
+  color: #710909;
  111
+  background-color: #fff;
  112
+  border-left: 26px solid #EE5757;
89 113
 }
90  
-h2#qunit-userAgent {
91  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
92  
-  background-color:#2b81af;
93  
-  margin:0;
94  
-  padding:0;
95  
-  color:#fff;
96  
-  font-size: small;
97  
-  padding:0.5em 0 0.5em 2.5em;
98  
-  text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
  114
+
  115
+#qunit-tests li.fail                        { color: #000000; background-color: #EE5757; }
  116
+#qunit-tests li.fail span.test-name,
  117
+#qunit-tests li.fail span.module-name       { color: #000000; }
  118
+
  119
+#qunit-tests li li.fail span.test-actual    { color: #EE5757; }
  120
+#qunit-tests li li.fail span.test-expected  { color: green;   }
  121
+
  122
+strong b.fail                               { color: #710909; }
  123
+
  124
+#qunit-banner.qunit-fail, 
  125
+#qunit-testrunner-toolbar                   { background-color: #EE5757; }
  126
+
  127
+
  128
+/** Footer */
  129
+
  130
+#qunit-testresult {
  131
+  padding: 0.5em 0.5em 0.5em 2.5em;
  132
+  
  133
+  color: #2b81af;
  134
+  background-color: #D2E0E6;
  135
+
  136
+  border-radius: 0 0 15px 15px;
  137
+  -moz-border-radius: 0 0 15px 15px;
  138
+  -webkit-border-bottom-right-radius: 15px;
  139
+  -webkit-border-bottom-left-radius: 15px;  
99 140
 }
100  
-p#qunit-testresult{
101  
-  font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
102  
-  margin:0;
103  
-  font-size: small;
104  
-  color:#2b81af;
105  
-  border-bottom-right-radius:15px;
106  
-  border-bottom-left-radius:15px;
107  
-  -moz-border-radius-bottomright:15px;
108  
-  -moz-border-radius-bottomleft:15px;
109  
-  -webkit-border-bottom-right-radius:15px;
110  
-  -webkit-border-bottom-left-radius:15px;
111  
-  background-color:#D2E0E6;
112  
-  padding:0.5em 0.5em 0.5em 2.5em;
  141
+
  142
+/** Fixture */
  143
+
  144
+#qunit-fixture {
  145
+  position: absolute;
  146
+  top: -10000px;
  147
+  left: -10000px;
113 148
 }
114  
-strong b.fail{
115  
-  color:#710909;
116  
-  }
117  
-strong b.pass{
118  
-  color:#5E740B;
119  
-  }
Txt external/qunit.js
  • View file @ dffcba0
... ...
@@ -12,37 +12,6 @@
12 12
 
13 13
 var QUnit = {
14 14
 
15  
-  // Initialize the configuration options
16  
-  init: function() {
17  
-    config = {
18  
-      stats: { all: 0, bad: 0 },
19  
-      moduleStats: { all: 0, bad: 0 },
20  
-      started: +new Date,
21  
-      updateRate: 1000,
22  
-      blocking: false,
23  
-      autorun: false,
24  
-      assertions: [],
25  
-      filters: [],
26  
-      queue: []
27  
-    };
28  
-
29  
-    var tests = id("qunit-tests"),
30  
-      banner = id("qunit-banner"),
31  
-      result = id("qunit-testresult");
32  
-
33  
-    if ( tests ) {
34  
-      tests.innerHTML = "";
35  
-    }
36  
-
37  
-    if ( banner ) {
38  
-      banner.className = "";
39  
-    }
40  
-
41  
-    if ( result ) {
42  
-      result.parentNode.removeChild( result );
43  
-    }
44  
-  },
45  
-  
46 15
   // call on start of module test to prepend name to all tests
47 16
   module: function(name, testEnvironment) {
48 17
     config.currentModule = name;
... ...
@@ -70,7 +39,7 @@ var QUnit = {
70 39
   },
71 40
   
72 41
   test: function(testName, expected, callback, async) {
73  
-    var name = testName, testEnvironment, testEnvironmentArg;
  42
+    var name = '<span class="test-name">' + testName + '</span>', testEnvironment, testEnvironmentArg;
74 43
 
75 44
     if ( arguments.length === 2 ) {
76 45
       callback = expected;
... ...
@@ -83,15 +52,14 @@ var QUnit = {
83 52
     }
84 53
 
85 54
     if ( config.currentModule ) {
86  
-      name = config.currentModule + " module: " + name;
  55
+      name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
87 56
     }
88 57
 
89  
-    if ( !validTest(name) ) {
  58
+    if ( !validTest(config.currentModule + ": " + testName) ) {
90 59
       return;
91 60
     }
92 61
 
93 62
     synchronize(function() {
94  
-      QUnit.testStart( testName );
95 63
 
96 64
       testEnvironment = extend({
97 65
         setup: function() {},
... ...
@@ -101,11 +69,23 @@ var QUnit = {
101 69
         extend(testEnvironment,testEnvironmentArg);
102 70
       }
103 71
 
  72
+      QUnit.testStart( testName, testEnvironment );
  73
+
104 74
       // allow utility functions to access the current test environment
105 75
       QUnit.current_testEnvironment = testEnvironment;
106 76
       
107 77
       config.assertions = [];
108 78
       config.expected = expected;
  79
+      
  80
+      var tests = id("qunit-tests");
  81
+      if (tests) {
  82
+        var b = document.createElement("strong");
  83
+          b.innerHTML = "Running " + name;
  84
+        var li = document.createElement("li");
  85
+          li.appendChild( b );
  86
+          li.id = "current-test-output";
  87
+        tests.appendChild( li )
  88
+      }
109 89
 
110 90
       try {
111 91
         if ( !config.pollution ) {
... ...
@@ -116,7 +96,9 @@ var QUnit = {
116 96
       } catch(e) {
117 97
         QUnit.ok( false, "Setup failed on " + name + ": " + e.message );
118 98
       }
119  
-
  99
+      });
  100
+  
  101
+      synchronize(function() {
120 102
       if ( async ) {
121 103
         QUnit.stop();
122 104
       }
... ...
@@ -143,7 +125,9 @@ var QUnit = {
143 125
       } catch(e) {
144 126
         QUnit.ok( false, "Teardown failed on " + name + ": " + e.message );
145 127
       }
146  
-
  128
+      });
  129
+  
  130
+      synchronize(function() {
147 131
       try {
148 132
         QUnit.reset();
149 133
       } catch(e) {
... ...
@@ -162,14 +146,13 @@ var QUnit = {
162 146
 
163 147
       if ( tests ) {
164 148
         var ol  = document.createElement("ol");
165  
-        ol.style.display = "none";
166 149
 
167 150
         for ( var i = 0; i < config.assertions.length; i++ ) {
168 151
           var assertion = config.assertions[i];
169 152
 
170 153
           var li = document.createElement("li");
171 154
           li.className = assertion.result ? "pass" : "fail";
172  
-          li.appendChild(document.createTextNode(assertion.message || "(no message)"));
  155
+          li.innerHTML = assertion.message || "(no message)";
173 156
           ol.appendChild( li );
174 157
 
175 158
           if ( assertion.result ) {
... ...
@@ -180,6 +163,9 @@ var QUnit = {
180 163
             config.moduleStats.bad++;
181 164
           }
182 165
         }
  166
+        if (bad == 0) {
  167
+          ol.style.display = "none";
  168
+        }
183 169
 
184 170
         var b = document.createElement("strong");
185 171
         b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>";
... ...
@@ -191,27 +177,20 @@ var QUnit = {
191 177
         
192 178
         addEvent(b, "dblclick", function(e) {
193 179
           var target = e && e.target ? e.target : window.event.srcElement;
194  
-          if ( target.nodeName.toLowerCase() === "strong" ) {
195  
-            var text = "", node = target.firstChild;
196  
-
197  
-            while ( node.nodeType === 3 ) {
198  
-              text += node.nodeValue;
199  
-              node = node.nextSibling;
200  
-            }
201  
-
202  
-            text = text.replace(/(^\s*|\s*$)/g, "");
203  
-
204  
-            if ( window.location ) {
205  
-              window.location.href = window.location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent(text);
206  
-            }
  180
+          if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
  181
+            target = target.parentNode;
  182
+          }
  183
+          if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
  184
+            window.location.search = "?" + encodeURIComponent(getText([target]).replace(/\(.+\)$/, "").replace(/(^\s*|\s*$)/g, ""));
207 185
           }
208 186
         });
209 187
 
210  
-        var li = document.createElement("li");
  188
+        var li = id("current-test-output");
  189
+        li.id = "";
211 190
         li.className = bad ? "fail" : "pass";
  191
+        li.removeChild( li.firstChild );
212 192
         li.appendChild( b );
213 193
         li.appendChild( ol );
214  
-        tests.appendChild( li );
215 194
 
216 195
         if ( bad ) {
217 196
           var toolbar = id("qunit-testrunner-toolbar");
... ...
@@ -262,6 +241,7 @@ var QUnit = {
262 241
    * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
263 242
    */
264 243
   ok: function(a, msg) {
  244
+    msg = escapeHtml(msg);
265 245
     QUnit.log(a, msg);
266 246
 
267 247
     config.assertions.push({
... ...
@@ -290,12 +270,12 @@ var QUnit = {
290 270
     push(expected != actual, actual, expected, message);
291 271
   },
292 272
   
293  
-  deepEqual: function(a, b, message) {
294  
-    push(QUnit.equiv(a, b), a, b, message);
  273
+  deepEqual: function(actual, expected, message) {
  274
+    push(QUnit.equiv(actual, expected), actual, expected, message);
295 275
   },
296 276
 
297  
-  notDeepEqual: function(a, b, message) {
298  
-    push(!QUnit.equiv(a, b), a, b, message);
  277
+  notDeepEqual: function(actual, expected, message) {
  278
+    push(!QUnit.equiv(actual, expected), actual, expected, message);
299 279
   },
300 280
 
301 281
   strictEqual: function(actual, expected, message) {
... ...
@@ -305,7 +285,17 @@ var QUnit = {
305 285
   notStrictEqual: function(actual, expected, message) {
306 286
     push(expected !== actual, actual, expected, message);
307 287
   },
308  
-  
  288
+
  289
+  raises: function(fn,  message) {
  290
+    try {
  291
+      fn();
  292
+      ok( false, message );
  293
+    }
  294
+    catch (e) {
  295
+      ok( true, message );
  296
+    }
  297
+  },
  298
+
309 299
   start: function() {
310 300
     // A slight delay, to avoid any current callbacks
311 301
     if ( window.setTimeout ) {
... ...
@@ -332,51 +322,8 @@ var QUnit = {
332 322
         QUnit.start();
333 323
       }, timeout);
334 324
     }
335  
-  },
336  
-  
337  
-  /**
338  
-   * Resets the test setup. Useful for tests that modify the DOM.
339  
-   */
340  
-  reset: function() {
341  
-    if ( window.jQuery ) {
342  
-      jQuery("#main").html( config.fixture );
343  
-      jQuery.event.global = {};
344  
-      jQuery.ajaxSettings = extend({}, config.ajaxSettings);
345  
-    }
346  
-  },
347  
-  
348  
-  /**
349  
-   * Trigger an event on an element.
350  
-   *
351  
-   * @example triggerEvent( document.body, "click" );
352  
-   *
353  
-   * @param DOMElement elem
354  
-   * @param String type
355  
-   */
356  
-  triggerEvent: function( elem, type, event ) {
357  
-    if ( document.createEvent ) {
358  
-      event = document.createEvent("MouseEvents");
359  
-      event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
360  
-        0, 0, 0, 0, 0, false, false, false, false, 0, null);
361  
-      elem.dispatchEvent( event );
  325
+  }
362 326
 
363  
-    } else if ( elem.fireEvent ) {
364  
-      elem.fireEvent("on"+type);
365  
-    }
366  
-  },
367  
-  
368  
-  // Safe object type checking
369  
-  is: function( type, obj ) {
370  
-    return Object.prototype.toString.call( obj ) === "[object "+ type +"]";
371  
-  },
372  
-  
373  
-  // Logging callbacks
374  
-  done: function(failures, total) {},
375  
-  log: function(result, message) {},
376  
-  testStart: function(name) {},
377  
-  testDone: function(name, failures, total) {},
378  
-  moduleStart: function(name, testEnvironment) {},
379  
-  moduleDone: function(name, failures, total) {}
380 327
 };
381 328
 
382 329
 // Backwards compatibility, deprecated
... ...
@@ -426,11 +373,127 @@ if ( typeof exports === "undefined" || typeof require === "undefined" ) {
426 373
   exports.QUnit = QUnit;
427 374
 }
428 375
 
  376
+// define these after exposing globals to keep them in these QUnit namespace only
  377
+extend(QUnit, {
  378
+  config: config,
  379
+
  380
+  // Initialize the configuration options
  381
+  init: function() {
  382
+    extend(config, {
  383
+      stats: { all: 0, bad: 0 },
  384
+      moduleStats: { all: 0, bad: 0 },
  385
+      started: +new Date,
  386
+      updateRate: 1000,
  387
+      blocking: false,
  388
+      autostart: true,
  389
+      autorun: false,
  390
+      assertions: [],
  391
+      filters: [],
  392
+      queue: []
  393
+    });
  394
+
  395
+    var tests = id("qunit-tests"),
  396
+      banner = id("qunit-banner"),
  397
+      result = id("qunit-testresult");
  398
+
  399
+    if ( tests ) {
  400
+      tests.innerHTML = "";
  401
+    }
  402
+
  403
+    if ( banner ) {
  404
+      banner.className = "";
  405
+    }
  406
+
  407
+    if ( result ) {
  408
+      result.parentNode.removeChild( result );
  409
+    }
  410
+  },
  411
+  
  412
+  /**
  413
+   * Resets the test setup. Useful for tests that modify the DOM.
  414
+   */
  415
+  reset: function() {
  416
+    if ( window.jQuery ) {
  417
+      jQuery("#main, #qunit-fixture").html( config.fixture );
  418
+    }
  419
+  },
  420
+  
  421
+  /**
  422
+   * Trigger an event on an element.
  423
+   *
  424
+   * @example triggerEvent( document.body, "click" );
  425
+   *
  426
+   * @param DOMElement elem
  427
+   * @param String type
  428
+   */
  429
+  triggerEvent: function( elem, type, event ) {
  430
+    if ( document.createEvent ) {
  431
+      event = document.createEvent("MouseEvents");
  432
+      event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
  433
+        0, 0, 0, 0, 0, false, false, false, false, 0, null);
  434
+      elem.dispatchEvent( event );
  435
+
  436
+    } else if ( elem.fireEvent ) {
  437
+      elem.fireEvent("on"+type);
  438
+    }
  439
+  },
  440
+  
  441
+  // Safe object type checking
  442
+  is: function( type, obj ) {
  443
+    return QUnit.objectType( obj ) == type;
  444
+  },
  445
+  
  446
+  objectType: function( obj ) {
  447
+    if (typeof obj === "undefined") {
  448
+        return "undefined";
  449
+
  450
+    // consider: typeof null === object
  451
+    }
  452
+    if (obj === null) {
  453
+        return "null";
  454
+    }
  455
+
  456
+    var type = Object.prototype.toString.call( obj )
  457
+      .match(/^\[object\s(.*)\]$/)[1] || '';
  458
+
  459
+    switch (type) {
  460
+        case 'Number':
  461
+            if (isNaN(obj)) {
  462
+                return "nan";
  463
+            } else {
  464
+                return "number";
  465
+            }
  466
+        case 'String':
  467
+        case 'Boolean':
  468
+        case 'Array':
  469
+        case 'Date':
  470
+        case 'RegExp':
  471
+        case 'Function':
  472
+            return type.toLowerCase();
  473
+    }
  474
+    if (typeof obj === "object") {
  475
+        return "object";
  476
+    }
  477
+    return undefined;
  478
+  },
  479
+  
  480
+  // Logging callbacks
  481
+  begin: function() {},
  482
+  done: function(failures, total) {},
  483
+  log: function(result, message) {},
  484
+  testStart: function(name, testEnvironment) {},
  485
+  testDone: function(name, failures, total) {},
  486
+  moduleStart: function(name, testEnvironment) {},
  487
+  moduleDone: function(name, failures, total) {}
  488
+});
  489
+
429 490
 if ( typeof document === "undefined" || document.readyState === "complete" ) {
430 491
   config.autorun = true;
431 492
 }
432 493
 
433 494
 addEvent(window, "load", function() {
  495
+  QUnit.begin();
  496
+  
434 497
   // Initialize the config, saving the execution queue
435 498
   var oldconfig = extend({}, config);
436 499
   QUnit.init();
... ...
@@ -486,16 +549,14 @@ addEvent(window, "load", function() {
486 549
     toolbar.appendChild( label );
487 550
   }
488 551
 
489  
-  var main = id('main');
  552
+  var main = id('main') || id('qunit-fixture');
490 553
   if ( main ) {
491 554
     config.fixture = main.innerHTML;
492 555
   }
493 556
 
494  
-  if ( window.jQuery ) {
495  
-    config.ajaxSettings = window.jQuery.ajaxSettings;
  557
+  if (config.autostart) {
  558
+    QUnit.start();
496 559
   }
497  
-
498  
-  QUnit.start();
499 560
 });
500 561
 
501 562
 function done() {
... ...
@@ -577,9 +638,36 @@ function validTest( name ) {
577 638
   return run;
578 639
 }
579 640
 
  641
+function escapeHtml(s) {
  642
+  s = s === null ? "" : s + "";
  643
+  return s.replace(/[\&"<>\\]/g, function(s) {
  644
+    switch(s) {
  645
+      case "&": return "&amp;";
  646
+      case "\\": return "\\\\";
  647
+      case '"': return '\"';
  648
+      case "<": return "&lt;";
  649
+      case ">": return "&gt;";
  650
+      default: return s;
  651
+    }
  652
+  });
  653
+}
  654
+
580 655
 function push(result, actual, expected, message) {
581  
-  message = message || (result ? "okay" : "failed");
582  
-  QUnit.ok( result, result ? message + ": " + QUnit.jsDump.parse(expected) : message + ", expected: " + QUnit.jsDump.parse(expected) + " result: " + QUnit.jsDump.parse(actual) );
  656
+  message = escapeHtml(message) || (result ? "okay" : "failed");
  657
+  message = '<span class="test-message">' + message + "</span>";
  658
+  expected = escapeHtml(QUnit.jsDump.parse(expected));
  659
+  actual = escapeHtml(QUnit.jsDump.parse(actual));
  660
+  var output = message + ', expected: <span class="test-expected">' + expected + '</span>';
  661
+  if (actual != expected) {
  662
+    output += ' result: <span class="test-actual">' + actual + '</span>, diff: ' + QUnit.diff(expected, actual);
  663
+  }
  664
+  
  665
+  // can't use ok, as that would double-escape messages
  666
+  QUnit.log(result, output);
  667
+  config.assertions.push({
  668
+    result: !!result,
  669
+    message: output
  670
+  });
583 671
 }
584 672
 
585 673
 function synchronize( callback ) {
... ...
@@ -690,60 +778,11 @@ QUnit.equiv = function () {
690 778
     var callers = []; // stack to decide between skip/abort functions
691 779
     var parents = []; // stack to avoiding loops from circular referencing
692 780
 
693  
-
694  
-    // Determine what is o.
695  
-    function hoozit(o) {
696  
-        if (QUnit.is("String", o)) {
697  
-            return "string";
698  
-            
699  
-        } else if (QUnit.is("Boolean", o)) {
700  
-            return "boolean";
701  
-
702  
-        } else if (QUnit.is("Number", o)) {
703  
-
704  
-            if (isNaN(o)) {
705  
-                return "nan";
706  
-            } else {
707  
-                return "number";
708  
-            }
709  
-
710  
-        } else if (typeof o === "undefined") {
711  
-            return "undefined";
712  
-
713  
-        // consider: typeof null === object
714  
-        } else if (o === null) {
715  
-            return "null";
716  
-
717  
-        // consider: typeof [] === object
718  
-        } else if (QUnit.is( "Array", o)) {
719  
-            return "array";
720  
-        
721  
-        // consider: typeof new Date() === object
722  
-        } else if (QUnit.is( "Date", o)) {
723  
-            return "date";
724  
-
725  
-        // consider: /./ instanceof Object;
726  
-        //           /./ instanceof RegExp;
727  
-        //          typeof /./ === "function"; // => false in IE and Opera,
728  
-        //                                          true in FF and Safari
729  
-        } else if (QUnit.is( "RegExp", o)) {
730  
-            return "regexp";
731  
-
732  
-        } else if (typeof o === "object") {
733  
-            return "object";
734  
-
735  
-        } else if (QUnit.is( "Function", o)) {
736  
-            return "function";
737  
-        } else {
738  
-            return undefined;
739  
-        }
740  
-    }
741  
-
742 781
     // Call the o related callback with the given arguments.
743 782
     function bindCallbacks(o, callbacks, args) {
744  
-        var prop = hoozit(o);
  783
+        var prop = QUnit.objectType(o);
745 784
         if (prop) {
746  
-            if (hoozit(callbacks[prop]) === "function") {
  785
+            if (QUnit.objectType(callbacks[prop]) === "function") {
747 786
                 return callbacks[prop].apply(callbacks, args);
748 787
             } else {
749 788
                 return callbacks[prop]; // or undefined
... ...
@@ -777,11 +816,11 @@ QUnit.equiv = function () {
777 816
             },
778 817
 
779 818
             "date": function (b, a) {
780  
-                return hoozit(b) === "date" && a.valueOf() === b.valueOf();
  819
+                return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
781 820
             },
782 821
 
783 822
             "regexp": function (b, a) {
784  
-                return hoozit(b) === "regexp" &&
  823
+                return QUnit.objectType(b) === "regexp" &&
785 824
                     a.source === b.source && // the regex itself
786 825
                     a.global === b.global && // and its modifers (gmi) ...
787 826
                     a.ignoreCase === b.ignoreCase &&
... ...
@@ -802,7 +841,7 @@ QUnit.equiv = function () {
802 841
                 var len;
803 842
 
804 843
                 // b could be an object literal here
805  
-                if ( ! (hoozit(b) === "array")) {
  844
+                if ( ! (QUnit.objectType(b) === "array")) {
806 845
                     return false;
807 846
                 }   
808 847
                 
... ...
@@ -880,7 +919,7 @@ QUnit.equiv = function () {
880 919
         return (function (a, b) {
881 920
             if (a === b) {
882 921
                 return true; // catch the most you can
883  
-            } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {
  922
+            } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
884 923
                 return false; // don't lose time with error prone cases
885 924
             } else {
886 925
                 return bindCallbacks(a, callbacks, [b, a]);
... ...
@@ -1066,4 +1105,161 @@ QUnit.jsDump = (function() {
1066 1105
   return jsDump;
1067 1106
 })();
1068 1107
 
  1108
+// from Sizzle.js
  1109
+function getText( elems ) {
  1110
+  var ret = "", elem;
  1111
+
  1112
+  for ( var i = 0; elems[i]; i++ ) {
  1113
+    elem = elems[i];
  1114
+
  1115
+    // Get the text from text nodes and CDATA nodes
  1116
+    if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
  1117
+      ret += elem.nodeValue;
  1118
+
  1119
+    // Traverse everything else, except comment nodes
  1120
+    } else if ( elem.nodeType !== 8 ) {
  1121
+      ret += getText( elem.childNodes );
  1122
+    }
  1123
+  }
  1124
+
  1125
+  return ret;
  1126
+};
  1127
+
  1128
+/*
  1129
+ * Javascript Diff Algorithm
  1130
+ *  By John Resig (http://ejohn.org/)
  1131
+ *  Modified by Chu Alan "sprite"
  1132
+ *
  1133
+ * Released under the MIT license.
  1134
+ *
  1135
+ * More Info:
  1136
+ *  http://ejohn.org/projects/javascript-diff-algorithm/
  1137
+ *  
  1138
+ * Usage: QUnit.diff(expected, actual)
  1139
+ * 
  1140
+ * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the  quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
  1141
+ */
  1142
+QUnit.diff = (function() {
  1143
+  function diff(o, n){
  1144
+    var ns = new Object();
  1145
+    var os = new Object();
  1146
+    
  1147
+    for (var i = 0; i < n.length; i++) {
  1148
+      if (ns[n[i]] == null) 
  1149
+        ns[n[i]] = {
  1150
+          rows: new Array(),
  1151
+          o: null
  1152
+        };
  1153
+      ns[n[i]].rows.push(i);
  1154
+    }
  1155
+    
  1156
+    for (var i = 0; i < o.length; i++) {
  1157
+      if (os[o[i]] == null) 
  1158
+        os[o[i]] = {
  1159
+          rows: new Array(),
  1160
+          n: null
  1161
+        };
  1162
+      os[o[i]].rows.push(i);
  1163
+    }
  1164
+    
  1165
+    for (var i in ns) {
  1166
+      if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
  1167
+        n[ns[i].rows[0]] = {
  1168
+          text: n[ns[i].rows[0]],
  1169
+          row: os[i].rows[0]
  1170
+        };
  1171
+        o[os[i].rows[0]] = {
  1172
+          text: o[os[i].rows[0]],
  1173
+          row: ns[i].rows[0]
  1174
+        };
  1175
+      }
  1176
+    }
  1177
+    
  1178
+    for (var i = 0; i < n.length - 1; i++) {
  1179
+      if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
  1180
+      n[i + 1] == o[n[i].row + 1]) {
  1181
+        n[i + 1] = {
  1182
+          text: n[i + 1],
  1183
+          row: n[i].row + 1
  1184
+        };
  1185
+        o[n[i].row + 1] = {
  1186
+          text: o[n[i].row + 1],
  1187
+          row: i + 1
  1188
+        };
  1189
+      }
  1190
+    }
  1191
+    
  1192
+    for (var i = n.length - 1; i > 0; i--) {
  1193
+      if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
  1194
+      n[i - 1] == o[n[i].row - 1]) {
  1195
+        n[i - 1] = {
  1196
+          text: n[i - 1],
  1197
+          row: n[i].row - 1
  1198
+        };
  1199
+        o[n[i].row - 1] = {
  1200
+          text: o[n[i].row - 1],
  1201
+          row: i - 1
  1202
+        };
  1203
+      }
  1204
+    }
  1205
+    
  1206
+    return {
  1207
+      o: o,
  1208
+      n: n
  1209
+    };
  1210
+  }
  1211
+  
  1212
+  return function(o, n){
  1213
+    o = o.replace(/\s+$/, '');
  1214
+    n = n.replace(/\s+$/, '');
  1215
+    var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
  1216
+
  1217
+    var str = "";
  1218
+    
  1219
+    var oSpace = o.match(/\s+/g);
  1220
+    if (oSpace == null) {
  1221
+      oSpace = [" "];
  1222
+    }
  1223
+    else {
  1224
+      oSpace.push(" ");
  1225
+    }
  1226
+    var nSpace = n.match(/\s+/g);
  1227
+    if (nSpace == null) {
  1228
+      nSpace = [" "];
  1229
+    }
  1230
+    else {
  1231
+      nSpace.push(" ");
  1232
+    }
  1233
+    
  1234
+    if (out.n.length == 0) {
  1235
+      for (var i = 0; i < out.o.length; i++) {
  1236
+        str += '<del>' + out.o[i] + oSpace[i] + "</del>";
  1237
+      }
  1238
+    }
  1239
+    else {
  1240
+      if (out.n[0].text == null) {
  1241
+        for (n = 0; n < out.o.length && out.o[n].text == null; n++) {
  1242
+          str += '<del>' + out.o[n] + oSpace[n] + "</del>";
  1243
+        }
  1244
+      }
  1245
+      
  1246
+      for (var i = 0; i < out.n.length; i++) {
  1247
+        if (out.n[i].text == null) {
  1248
+          str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
  1249
+        }
  1250
+        else {
  1251
+          var pre = "";
  1252
+          
  1253
+          for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
  1254
+            pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
  1255
+          }
  1256
+          str += " " + out.n[i].text + nSpace[i] + pre;
  1257
+        }
  1258
+      }
  1259
+    }
  1260
+    
  1261
+    return str;
  1262
+  }
  1263
+})();
  1264
+
1069 1265
 })(this);
Txt tests/unit/slider/slider_events.js
  • View file @ dffcba0
... ...
@@ -72,7 +72,7 @@ test( "programmatic event triggers", function() {
72 72
     })
73 73
     .slider( "value", 0 );
74 74
 
75  
-  reset();
  75
+  QUnit.reset();
76 76
   // Test values method
77 77
   el = $( "<div></div>" )
78 78
     .slider({
... ...
@@ -83,7 +83,7 @@ test( "programmatic event triggers", function() {
83 83
     })
84 84
     .slider( "values", [80, 90] );
85 85
 
86  
-  reset();
  86
+  QUnit.reset();
87 87
   // Test value option
88 88
   el = $( "<div></div>" )
89 89
     .slider({
... ...
@@ -93,7 +93,7 @@ test( "programmatic event triggers", function() {
93 93
     })
94 94
     .slider( "option", "value", 0 );
95 95
 
96  
-  reset();
  96
+  QUnit.reset();
97 97
   // Test values option
98 98
   el = $( "<div></div>" )
99 99
     .slider({

0 notes on commit dffcba0

Please log in to comment.
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • Русский
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Русский
  • Српски
  • Svenska
  • 中文

Keyboard Shortcuts

Site wide shortcuts

s
Focus site search
?
Bring up this help dialog

Commit list

j
Move selected down
k
Move selected up
t
Open tree
p
Open parent
c or o or enter
Open commit

Pull request list

j
Move selected down
k
Move selected up
o or enter
Open issue

Issues

j
Move selected down
k
Move selected up
x
Toggle select target
o or enter
Open issue
I
Mark selected as read
U
Mark selected as unread
e
Close selected
y
Remove selected from view
c
Create issue
l
Create label
i
Back to inbox
u
Back to issues
/
Focus issues search

Network Graph

← or h
Scroll left
→ or l
Scroll right
↑ or k
Scroll up
↓ or j
Scroll down
t
Toggle visibility of head labels
shift ← or shift h
Scroll all the way left
shift → or shift l
Scroll all the way right
shift ↑ or shift k
Scroll all the way up
shift ↓ or shift j
Scroll all the way down