Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
7,506 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
.project | |||
*~ | |||
*.diff | |||
*.patch | |||
.DS_Store | |||
.settings | |||
node_modules | |||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
Jörn Zaefferer <joern.zaefferer@gmail.com> | |||
Ariel Flesler <aflesler@gmail.com> | |||
Scott González <scott.gonzalez@gmail.com> | |||
Richard Worth <rdworth@gmail.com> | |||
Philippe Rathé <prathe@gmail.com> | |||
John Resig <jeresig@gmail.com> | |||
Will Moffat <will_git@hamstersoup.com> | |||
Jan Kassens <jan@kassens.net> | |||
Ziling Zhao <zizhao@cisco.com> | |||
Ryan Szulczewski <musicmanryan@gmail.com> | |||
Chris Lloyd <christopher.lloyd@gmail.com> | |||
Louis-Rémi Babé <public@lrbabe.com> | |||
Jake Archibald <jake.archibald@bbc.co.uk> | |||
Frances Berriman <frances.berriman@bbc.co.uk> | |||
Rune Halvorsen <runefh@gmail.com> | |||
Chris Thatcher <thatcher.christopher@gmail.com> | |||
Fábio Rehm <fgrehm@gmail.com> | |||
Leon Sorokin <leeoniya@gmail.com> | |||
Douglas Neiner <doug@pixelgraphics.us> | |||
Paul Elliott <paul@hashrocket.com> | |||
Nikita Vasilyev <me@elv1s.ru> | |||
Benjamin Lee <leebenjp@gmail.com> | |||
Paul Irish <paul.irish@gmail.com> | |||
Oleg Slobodskoi <oleg008@gmail.com> | |||
Anton Matzneller <obhvsbypqghgc@gmail.com> | |||
Aurélien Bombo | |||
Mathias Bynens <mathias@qiwi.be> | |||
Erik Vold <erikvvold@gmail.com> | |||
Wesley Walser <waw325@gmail.com> | |||
Rob Kinninmont <robk@twitter.com> | |||
Marc Portier <marc.portier@gmail.com> | |||
Michael Righi <michael@righi.me> | |||
Timo Tijhof <krinklemail@gmail.com> | |||
Jan Alonzo <jmalonzo@taguchimail.com> | |||
Daniel Trebbien <dtrebbien@gmail.com> | |||
Bob Fanger <bfanger@gmail.com> | |||
Markus Messner-Chaney <markus.messner-chaney@xing.com> | |||
Trevor Parscal <trevorparscal@gmail.com> | |||
Ashar Voultoiz <hashar@free.fr> | |||
Jimmy Mabey <jimmy@velsoft.com> | |||
Domenic Denicola <domenic@domenicdenicola.com> | |||
Mike Sherov <mike.sherov@gmail.com> | |||
Seong-A Kong <simonz@daumcorp.com> | |||
Graham Conzett <conzett@gmail.com> | |||
Niall Smart <niall@pobox.com> | |||
Johan Sörlin <spocke@moxiecode.com> | |||
Gijs Kruitbosch <gijskruitbosch@gmail.com> | |||
Erkan Yilmaz <erkan77@gmail.com> | |||
Jonathan Sanchez <jsanchezpando@cirb.irisnet.be> | |||
Keith Cirkel <github@keithcirkel.co.uk> | |||
Rick Waldron <waldron.rick@gmail.com> | |||
Herbert Vojčík <herby@mailbox.sk> | |||
Richard Gibson <richard.gibson@gmail.com> | |||
Alex J Burke <alex@alexjeffburke.com> | |||
Sergii Kliuchnyk <sergiikliuchnyk@gmail.com> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
[QUnit](http://qunitjs.com) - A JavaScript Unit Testing framework. | |||
================================ | |||
|
|||
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery | |||
project to test its code and plugins but is capable of testing any generic | |||
JavaScript code (and even capable of testing JavaScript code on the server-side). | |||
|
|||
QUnit is especially useful for regression testing: Whenever a bug is reported, | |||
write a test that asserts the existence of that particular bug. Then fix it and | |||
commit both. Every time you work on the code again, run the tests. If the bug | |||
comes up again - a regression - you'll spot it immediately and know how to fix | |||
it, because you know what code you just changed. | |||
|
|||
Having good unit test coverage makes safe refactoring easy and cheap. You can | |||
run the tests after each small refactoring step and always know what change | |||
broke something. | |||
|
|||
QUnit is similar to other unit testing frameworks like JUnit, but makes use of | |||
the features JavaScript provides and helps with testing code in the browser, e.g. | |||
with its stop/start facilities for testing asynchronous code. | |||
|
|||
If you are interested in helping developing QUnit, you are in the right place. | |||
For related discussions, visit the | |||
[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing). | |||
|
|||
Development | |||
----------- | |||
|
|||
To submit patches, fork the repository, create a branch for the change. Then implement | |||
the change, run `grunt` to lint and test it, then commit, push and create a pull request. | |||
|
|||
Include some background for the change in the commit message and `Fixes #nnn`, referring | |||
to the issue number you're addressing. | |||
|
|||
To run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global | |||
grunt binary. For additional grunt tasks, also run `npm install`. | |||
|
|||
Releases | |||
-------- | |||
|
|||
Install git-extras and run `git changelog` to update History.md. | |||
Update qunit/qunit.js|css and package.json to the release version, commit and | |||
tag, update them again to the next version, commit and push commits and tags | |||
(`git push --tags origin master`). | |||
|
|||
Put the 'v' in front of the tag, e.g. `v1.8.0`. Clean up the changelog, removing merge commits | |||
or whitespace cleanups. | |||
|
|||
To upload to code.jquery.com (replace $version accordingly), ssh to code.origin.jquery.com: | |||
|
|||
cp qunit/qunit.js /var/www/html/code.jquery.com/qunit/qunit-$version.js | |||
cp qunit/qunit.css /var/www/html/code.jquery.com/qunit/qunit-$version.css | |||
|
|||
Then update /var/www/html/code.jquery.com/index.html and purge it with: | |||
|
|||
curl -s http://code.origin.jquery.com/?reload | |||
|
|||
Update web-base-template to link to those files for qunitjs.com. | |||
|
|||
Publish to npm via | |||
|
|||
npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
{ | |||
"browser": true, | |||
"curly": true, | |||
"eqnull": true, | |||
"eqeqeq": true, | |||
"expr": true, | |||
"evil": true, | |||
"jquery": true, | |||
"latedef": true, | |||
"noarg": true, | |||
"onevar": true, | |||
"smarttabs": true, | |||
"trailing": true, | |||
"undef": true, | |||
"predef": [ | |||
"module", | |||
"test", | |||
"asyncTest", | |||
"expect", | |||
"start", | |||
"stop", | |||
"QUnit" | |||
] | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
Canvas - A QUnit addon for testing Canvas rendering | |||
================================ | |||
|
|||
This addon for QUnit adds a `QUnit.pixelEqual` method that allows you to assert | |||
individual pixel values in a given canvas. | |||
|
|||
### Usage ### | |||
|
|||
```js | |||
QUnit.pixelEqual(canvas, x, y, r, g, b, a, message); | |||
``` | |||
|
|||
Where: | |||
- `canvas`: Reference to a canvas element | |||
- `x`, `y`: Coordinates of the pixel to test | |||
- `r`, `g`, `b`, `a`: The color and opacity value of the pixel that you except | |||
- `message`: Optional message, same as for other assertions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,76 @@ | |||
test("Canvas pixels", function () { | |||
var canvas = document.getElementById('qunit-canvas'), context; | |||
try { | |||
context = canvas.getContext('2d'); | |||
} catch(e) { | |||
// propably no canvas support, just exit | |||
return; | |||
} | |||
context.fillStyle = 'rgba(0, 0, 0, 0)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(255, 0, 0, 0)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 255, 0, 0)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 0, 255, 0)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0); | |||
context.clearRect(0,0,5,5); | |||
|
|||
context.fillStyle = 'rgba(0, 0, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(255, 0, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 255, 0, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 255, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 255, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 0, 255, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 255, 153); | |||
context.clearRect(0,0,5,5); | |||
|
|||
context.fillStyle = 'rgba(0, 0, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(255, 0, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 2, 2, 255, 0, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 255, 0, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 2, 2, 0, 255, 0, 153); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 0, 255, 0.6)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 255, 153); | |||
context.clearRect(0,0,5,5); | |||
|
|||
context.fillStyle = 'rgba(0, 0, 0, 1)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 0, 255); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(255, 0, 0, 1)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 4, 4, 255, 0, 0, 255); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 255, 0, 1)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 4, 4, 0, 255, 0, 255); | |||
context.clearRect(0,0,5,5); | |||
context.fillStyle = 'rgba(0, 0, 255, 1)'; | |||
context.fillRect(0, 0, 5, 5); | |||
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 255, 255); | |||
context.clearRect(0,0,5,5); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="UTF-8"> | |||
<title>QUnit Test Suite - Canvas Addon</title> | |||
<link rel="stylesheet" href="../../qunit/qunit.css"> | |||
<script src="../../qunit/qunit.js"></script> | |||
<script src="qunit-canvas.js"></script> | |||
<script src="canvas-test.js"></script> | |||
</head> | |||
<body> | |||
<div id="qunit"></div> | |||
<canvas id="qunit-canvas" width="5" height="5"></canvas> | |||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
QUnit.extend( QUnit, { | |||
pixelEqual: function(canvas, x, y, r, g, b, a, message) { | |||
var actual = Array.prototype.slice.apply(canvas.getContext('2d').getImageData(x, y, 1, 1).data), expected = [r, g, b, a]; | |||
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message); | |||
} | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
Close-Enough - A QUnit addon for testing number approximations | |||
================================ | |||
|
|||
This addon for QUnit adds `QUnit.close` and `QUnit.notClose` assertion methods to test that | |||
numbers are close enough (or different enough) from an expected number, with | |||
a specified accuracy. | |||
|
|||
### Usage ### | |||
|
|||
```js | |||
QUnit.close(actual, expected, maxDifference, message); | |||
QUnit.notClose(actual, expected, minDifference, message); | |||
``` | |||
|
|||
Where: | |||
- `maxDifference`: the maximum inclusive difference allowed between the `actual` and `expected` numbers | |||
- `minDifference`: the minimum exclusive difference allowed between the `actual` and `expected` numbers | |||
- `actual`, `expected`, `message`: The usual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
test("Close Numbers", function () { | |||
var halfPi = Math.PI / 2, | |||
sqrt2 = Math.sqrt(2); | |||
|
|||
QUnit.close(7, 7, 0); | |||
QUnit.close(7, 7.1, 0.1); | |||
QUnit.close(7, 7.1, 0.2); | |||
|
|||
QUnit.close(3.141, Math.PI, 0.001); | |||
QUnit.close(3.1, Math.PI, 0.1); | |||
|
|||
QUnit.close(halfPi, 1.57, 0.001); | |||
|
|||
QUnit.close(sqrt2, 1.4142, 0.0001); | |||
|
|||
QUnit.close(Infinity, Infinity, 1); | |||
}); | |||
|
|||
test("Distant Numbers", function () { | |||
var halfPi = Math.PI / 2, | |||
sqrt2 = Math.sqrt(2); | |||
|
|||
QUnit.notClose(6, 7, 0); | |||
QUnit.notClose(7, 7.2, 0.1); | |||
QUnit.notClose(7, 7.2, 0.19999999999); | |||
|
|||
QUnit.notClose(3.141, Math.PI, 0.0001); | |||
QUnit.notClose(3.1, Math.PI, 0.001); | |||
|
|||
QUnit.notClose(halfPi, 1.57, 0.0001); | |||
|
|||
QUnit.notClose(sqrt2, 1.4142, 0.00001); | |||
|
|||
QUnit.notClose(Infinity, -Infinity, 5); | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="UTF-8"> | |||
<title>QUnit Test Suite - Close Enough Addon</title> | |||
<link rel="stylesheet" href="../../qunit/qunit.css"> | |||
<script src="../../qunit/qunit.js"></script> | |||
<script src="qunit-close-enough.js"></script> | |||
<script src="close-enough-test.js"></script> | |||
</head> | |||
<body> | |||
<div id="qunit"></div> | |||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,32 @@ | |||
QUnit.extend( QUnit, { | |||
/** | |||
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal | |||
* based on a specified maximum allowable difference. | |||
* | |||
* @example close(3.141, Math.PI, 0.001); | |||
* | |||
* @param Number actual | |||
* @param Number expected | |||
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers) | |||
* @param String message (optional) | |||
*/ | |||
close: function(actual, expected, maxDifference, message) { | |||
var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference; | |||
QUnit.push(passes, actual, expected, message); | |||
}, | |||
|
|||
/** | |||
* Checks that the first two arguments are numbers with differences greater than the specified | |||
* minimum difference. | |||
* | |||
* @example notClose(3.1, Math.PI, 0.001); | |||
* | |||
* @param Number actual | |||
* @param Number expected | |||
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers) | |||
* @param String message (optional) | |||
*/ | |||
notClose: function(actual, expected, minDifference, message) { | |||
QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message); | |||
} | |||
}); |
Oops, something went wrong.