Skip to content

Commit f68d655

Browse files
committed
Build: Update dependencies, including QUnit 1 -> 2
Also, fix htmllint lang exclusion patterns. Ref gh-2157
1 parent 43ed5c9 commit f68d655

File tree

9 files changed

+7370
-3821
lines changed

9 files changed

+7370
-3821
lines changed

Gruntfile.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ grunt.initConfig( {
182182
good: {
183183
options: {
184184
ignore: [
185-
/The text content of element script was not in the required format: Expected space, tab, newline, or slash but found . instead/
186-
] },
185+
/The text content of element script was not in the required format: Expected space, tab, newline, or slash but found . instead/,
186+
/This document appears to be written in .*. Consider using lang=".*" \(or variant\) instead/
187+
]
188+
},
187189
src: [
188190
"{demos,tests}/**/*.html",
189191
...htmllintBad.map( pattern => `!${ pattern }` )
@@ -197,7 +199,7 @@ grunt.initConfig( {
197199
/Element object is missing one or more of the following/,
198200
/The codebase attribute on the object element is obsolete/,
199201
/Consider adding a lang attribute to the html start tag/,
200-
/This document appears to be written in .*. Consider adding lang=".*" \(or variant\) to the html start tag/
202+
/This document appears to be written in .*. Consider (?:adding|using) lang=".*" \(or variant\)/
201203
]
202204
},
203205
src: htmllintBad

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"jquery-color": "2.2.0",
1616
"jquery-mousewheel": "3.1.12",
1717
"jquery-simulate": "1.1.1",
18-
"qunit": "1.18.0",
18+
"qunit": "2.19.4",
1919
"qunit-assert-classes": "1.0.2",
20-
"qunit-assert-close": "JamesMGreene/qunit-assert-close#v1.1.1",
21-
"qunit-composite": "JamesMGreene/qunit-composite#v1.1.0",
20+
"qunit-assert-close": "JamesMGreene/qunit-assert-close#v2.1.2",
21+
"qunit-composite": "JamesMGreene/qunit-composite#v2.0.0",
2222
"requirejs": "2.1.14",
2323

2424
"jquery-1.8.0": "jquery#1.8.0",
Lines changed: 172 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,182 @@
1-
/**
2-
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
3-
* based on a specified maximum allowable difference.
4-
*
5-
* @example assert.close(3.141, Math.PI, 0.001);
6-
*
7-
* @param Number actual
8-
* @param Number expected
9-
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
10-
* @param String message (optional)
11-
*/
12-
function close(actual, expected, maxDifference, message) {
13-
var actualDiff = (actual === expected) ? 0 : Math.abs(actual - expected),
14-
result = actualDiff <= maxDifference;
15-
message = message || (actual + " should be within " + maxDifference + " (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
16-
QUnit.push(result, actual, expected, message);
17-
}
18-
19-
20-
/**
21-
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
22-
* based on a specified maximum allowable difference percentage.
23-
*
24-
* @example assert.close.percent(155, 150, 3.4); // Difference is ~3.33%
25-
*
26-
* @param Number actual
27-
* @param Number expected
28-
* @param Number maxPercentDifference (the maximum inclusive difference percentage allowed between the actual and expected numbers)
29-
* @param String message (optional)
30-
*/
31-
close.percent = function closePercent(actual, expected, maxPercentDifference, message) {
32-
var actualDiff, result;
33-
if (actual === expected) {
34-
actualDiff = 0;
35-
result = actualDiff <= maxPercentDifference;
1+
(function(factory) {
2+
3+
// NOTE:
4+
// All techniques except for the "browser globals" fallback will extend the
5+
// provided QUnit object but return the isolated API methods
6+
7+
// For AMD: Register as an anonymous AMD module with a named dependency on "qunit".
8+
if (typeof define === "function" && define.amd) {
9+
define(["qunit"], factory);
10+
}
11+
// For Node.js
12+
else if (typeof module !== "undefined" && module && module.exports && typeof require === "function") {
13+
module.exports = factory(require("qunitjs"));
3614
}
37-
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
38-
actualDiff = Math.abs(100 * (actual - expected) / expected);
39-
result = actualDiff <= maxPercentDifference;
15+
// For CommonJS with `exports`, but without `module.exports`, like Rhino
16+
else if (typeof exports !== "undefined" && exports && typeof require === "function") {
17+
var qunit = require("qunitjs");
18+
qunit.extend(exports, factory(qunit));
4019
}
20+
// For browser globals
4121
else {
42-
// Dividing by zero (0)! Should return `false` unless the max percentage was `Infinity`
43-
actualDiff = Infinity;
44-
result = maxPercentDifference === Infinity;
22+
factory(QUnit);
4523
}
46-
message = message || (actual + " should be within " + maxPercentDifference + "% (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));
47-
48-
QUnit.push(result, actual, expected, message);
49-
};
50-
51-
52-
/**
53-
* Checks that the first two arguments are numbers with differences greater than the specified
54-
* minimum difference.
55-
*
56-
* @example assert.notClose(3.1, Math.PI, 0.001);
57-
*
58-
* @param Number actual
59-
* @param Number expected
60-
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
61-
* @param String message (optional)
62-
*/
63-
function notClose(actual, expected, minDifference, message) {
64-
var actualDiff = Math.abs(actual - expected),
65-
result = actualDiff > minDifference;
66-
message = message || (actual + " should not be within " + minDifference + " (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
67-
QUnit.push(result, actual, expected, message);
68-
}
69-
70-
71-
/**
72-
* Checks that the first two arguments are numbers with differences greater than the specified
73-
* minimum difference percentage.
74-
*
75-
* @example assert.notClose.percent(156, 150, 3.5); // Difference is 4.0%
76-
*
77-
* @param Number actual
78-
* @param Number expected
79-
* @param Number minPercentDifference (the minimum exclusive difference percentage allowed between the actual and expected numbers)
80-
* @param String message (optional)
81-
*/
82-
notClose.percent = function notClosePercent(actual, expected, minPercentDifference, message) {
83-
var actualDiff, result;
84-
if (actual === expected) {
85-
actualDiff = 0;
86-
result = actualDiff > minPercentDifference;
24+
25+
}(function(QUnit) {
26+
27+
/**
28+
* Find an appropriate `Assert` context to `push` results to.
29+
* @param * context - An unknown context, possibly `Assert`, `Test`, or neither
30+
* @private
31+
*/
32+
function _getPushContext(context) {
33+
var pushContext;
34+
35+
if (context && typeof context.push === "function") {
36+
// `context` is an `Assert` context
37+
pushContext = context;
38+
}
39+
else if (context && context.assert && typeof context.assert.push === "function") {
40+
// `context` is a `Test` context
41+
pushContext = context.assert;
42+
}
43+
else if (
44+
QUnit && QUnit.config && QUnit.config.current && QUnit.config.current.assert &&
45+
typeof QUnit.config.current.assert.push === "function"
46+
) {
47+
// `context` is an unknown context but we can find the `Assert` context via QUnit
48+
pushContext = QUnit.config.current.assert;
49+
}
50+
else if (QUnit && typeof QUnit.push === "function") {
51+
pushContext = QUnit.push;
52+
}
53+
else {
54+
throw new Error("Could not find the QUnit `Assert` context to push results");
55+
}
56+
57+
return pushContext;
8758
}
88-
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
89-
actualDiff = Math.abs(100 * (actual - expected) / expected);
90-
result = actualDiff > minPercentDifference;
59+
60+
/**
61+
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
62+
* based on a specified maximum allowable difference.
63+
*
64+
* @example assert.close(3.141, Math.PI, 0.001);
65+
*
66+
* @param Number actual
67+
* @param Number expected
68+
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
69+
* @param String message (optional)
70+
*/
71+
function close(actual, expected, maxDifference, message) {
72+
var actualDiff = (actual === expected) ? 0 : Math.abs(actual - expected),
73+
result = actualDiff <= maxDifference,
74+
pushContext = _getPushContext(this);
75+
76+
message = message || (actual + " should be within " + maxDifference + " (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
77+
78+
pushContext.push(result, actual, expected, message);
9179
}
92-
else {
93-
// Dividing by zero (0)! Should only return `true` if the min percentage was `Infinity`
94-
actualDiff = Infinity;
95-
result = minPercentDifference !== Infinity;
80+
81+
82+
/**
83+
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
84+
* based on a specified maximum allowable difference percentage.
85+
*
86+
* @example assert.close.percent(155, 150, 3.4); // Difference is ~3.33%
87+
*
88+
* @param Number actual
89+
* @param Number expected
90+
* @param Number maxPercentDifference (the maximum inclusive difference percentage allowed between the actual and expected numbers)
91+
* @param String message (optional)
92+
*/
93+
close.percent = function closePercent(actual, expected, maxPercentDifference, message) {
94+
var actualDiff, result,
95+
pushContext = _getPushContext(this);
96+
97+
if (actual === expected) {
98+
actualDiff = 0;
99+
result = actualDiff <= maxPercentDifference;
100+
}
101+
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
102+
actualDiff = Math.abs(100 * (actual - expected) / expected);
103+
result = actualDiff <= maxPercentDifference;
104+
}
105+
else {
106+
// Dividing by zero (0)! Should return `false` unless the max percentage was `Infinity`
107+
actualDiff = Infinity;
108+
result = maxPercentDifference === Infinity;
109+
}
110+
message = message || (actual + " should be within " + maxPercentDifference + "% (inclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));
111+
112+
pushContext.push(result, actual, expected, message);
113+
};
114+
115+
116+
/**
117+
* Checks that the first two arguments are numbers with differences greater than the specified
118+
* minimum difference.
119+
*
120+
* @example assert.notClose(3.1, Math.PI, 0.001);
121+
*
122+
* @param Number actual
123+
* @param Number expected
124+
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
125+
* @param String message (optional)
126+
*/
127+
function notClose(actual, expected, minDifference, message) {
128+
var actualDiff = Math.abs(actual - expected),
129+
result = actualDiff > minDifference,
130+
pushContext = _getPushContext(this);
131+
132+
message = message || (actual + " should not be within " + minDifference + " (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff));
133+
134+
pushContext.push(result, actual, expected, message);
96135
}
97-
message = message || (actual + " should not be within " + minPercentDifference + "% (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));
98136

99-
QUnit.push(result, actual, expected, message);
100-
};
101137

138+
/**
139+
* Checks that the first two arguments are numbers with differences greater than the specified
140+
* minimum difference percentage.
141+
*
142+
* @example assert.notClose.percent(156, 150, 3.5); // Difference is 4.0%
143+
*
144+
* @param Number actual
145+
* @param Number expected
146+
* @param Number minPercentDifference (the minimum exclusive difference percentage allowed between the actual and expected numbers)
147+
* @param String message (optional)
148+
*/
149+
notClose.percent = function notClosePercent(actual, expected, minPercentDifference, message) {
150+
var actualDiff, result,
151+
pushContext = _getPushContext(this);
152+
153+
if (actual === expected) {
154+
actualDiff = 0;
155+
result = actualDiff > minPercentDifference;
156+
}
157+
else if (actual !== 0 && expected !== 0 && expected !== Infinity && expected !== -Infinity) {
158+
actualDiff = Math.abs(100 * (actual - expected) / expected);
159+
result = actualDiff > minPercentDifference;
160+
}
161+
else {
162+
// Dividing by zero (0)! Should only return `true` if the min percentage was `Infinity`
163+
actualDiff = Infinity;
164+
result = minPercentDifference !== Infinity;
165+
}
166+
message = message || (actual + " should not be within " + minPercentDifference + "% (exclusive) of " + expected + (result ? "" : ". Actual: " + actualDiff + "%"));
167+
168+
pushContext.push(result, actual, expected, message);
169+
};
170+
171+
172+
var api = {
173+
close: close,
174+
notClose: notClose,
175+
closePercent: close.percent,
176+
notClosePercent: notClose.percent
177+
};
178+
179+
QUnit.extend(QUnit.assert, api);
102180

103-
QUnit.extend(QUnit.assert, {
104-
close: close,
105-
notClose: notClose
106-
});
181+
return api;
182+
}));

external/qunit-composite/qunit-composite.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,37 @@
1111

1212
background: #fff;
1313
}
14+
15+
#qunit-testsuites {
16+
margin: 0;
17+
padding: 0.5em 1.0em;
18+
font-family: "Helvetica Neue Light","HelveticaNeue-Light","Helvetica Neue",Calibri,Helvetica,Arial,sans-serif;
19+
font-size: small;
20+
background-color: #d2e0e6;
21+
border-bottom: 1px solid #fff;
22+
}
23+
24+
#qunit-testsuites a {
25+
color: #00c;
26+
text-decoration: none;
27+
}
28+
29+
#qunit-testsuites a:hover {
30+
text-decoration: underline;
31+
}
32+
33+
#qunit-testsuites > li {
34+
display: inline-block;
35+
}
36+
37+
#qunit-testsuites > li:first-child::before {
38+
content: "Suites: ";
39+
}
40+
41+
#qunit-testsuites > li + li::before {
42+
content: "|\a0";
43+
}
44+
45+
#qunit-testsuites > li::after {
46+
content: "\a0";
47+
}

0 commit comments

Comments
 (0)