everqueen 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +163 -0
- data/bin/everqueen +18 -0
- data/config/routes.rb +3 -0
- data/lib/everqueen.rb +66 -0
- data/lib/everqueen/application.rb +47 -0
- data/lib/everqueen/assets/elabs.png +0 -0
- data/lib/everqueen/assets/everqueen.scss.css +370 -0
- data/lib/everqueen/assets/jquery.js +152 -0
- data/lib/everqueen/assets/json2.js +25 -0
- data/lib/everqueen/assets/list.js.coffee +35 -0
- data/lib/everqueen/assets/run.js.coffee.erb +39 -0
- data/lib/everqueen/assets/start.js.coffee +6 -0
- data/lib/everqueen/assets/test_helper.js +3 -0
- data/lib/everqueen/cli.rb +29 -0
- data/lib/everqueen/rails.rb +14 -0
- data/lib/everqueen/runner.rb +151 -0
- data/lib/everqueen/server.rb +19 -0
- data/lib/everqueen/suite.rb +32 -0
- data/lib/everqueen/tasks.rb +10 -0
- data/lib/everqueen/test.rb +44 -0
- data/lib/everqueen/version.rb +3 -0
- data/lib/everqueen/views/_test_error.erb +4 -0
- data/lib/everqueen/views/layout.erb +17 -0
- data/lib/everqueen/views/list.erb +19 -0
- data/lib/everqueen/views/run.erb +20 -0
- data/lib/qunit/History.md +330 -0
- data/lib/qunit/README.md +37 -0
- data/lib/qunit/addons/canvas/README.md +16 -0
- data/lib/qunit/addons/canvas/canvas-test.js +76 -0
- data/lib/qunit/addons/canvas/canvas.html +19 -0
- data/lib/qunit/addons/canvas/qunit-canvas.js +6 -0
- data/lib/qunit/addons/close-enough/README.md +17 -0
- data/lib/qunit/addons/close-enough/close-enough-test.js +37 -0
- data/lib/qunit/addons/close-enough/close-enough.html +18 -0
- data/lib/qunit/addons/close-enough/qunit-close-enough.js +32 -0
- data/lib/qunit/addons/composite/README.md +7 -0
- data/lib/qunit/addons/composite/composite-demo-test.html +33 -0
- data/lib/qunit/addons/composite/composite-test.html +20 -0
- data/lib/qunit/addons/composite/composite-test.js +159 -0
- data/lib/qunit/addons/composite/dummy-qunit-test.html +19 -0
- data/lib/qunit/addons/composite/dummy-same-test.html +19 -0
- data/lib/qunit/addons/composite/index.html +35 -0
- data/lib/qunit/addons/composite/qunit-composite.css +13 -0
- data/lib/qunit/addons/composite/qunit-composite.js +82 -0
- data/lib/qunit/addons/step/README.md +18 -0
- data/lib/qunit/addons/step/qunit-step.js +25 -0
- data/lib/qunit/addons/step/step-test.js +13 -0
- data/lib/qunit/addons/step/step.html +19 -0
- data/lib/qunit/package.json +28 -0
- data/lib/qunit/qunit/qunit.css +226 -0
- data/lib/qunit/qunit/qunit.js +1597 -0
- data/lib/qunit/test/headless.html +24 -0
- data/lib/qunit/test/index.html +21 -0
- data/lib/qunit/test/logs.html +17 -0
- data/lib/qunit/test/logs.js +153 -0
- data/lib/qunit/test/same.js +1432 -0
- data/lib/qunit/test/swarminject.js +9 -0
- data/lib/qunit/test/test.js +524 -0
- data/lib/tasks/everqueen.rake +8 -0
- data/spec/everqueen_spec.rb +52 -0
- data/spec/meta_spec.rb +40 -0
- data/spec/runner_spec.rb +32 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/suite1/public/jquery.js +152 -0
- data/spec/suite1/public/styles.css +3 -0
- data/spec/suite1/test/javascripts/bar_test.js +0 -0
- data/spec/suite1/test/javascripts/coffeescript_test.coffee +7 -0
- data/spec/suite1/test/javascripts/failing_test.js +9 -0
- data/spec/suite1/test/javascripts/foo_test.js +0 -0
- data/spec/suite1/test/javascripts/libs/lucid_test.js +0 -0
- data/spec/suite1/test/javascripts/models/game_test.js +0 -0
- data/spec/suite1/test/javascripts/slow_test.coffee +8 -0
- data/spec/suite1/test/javascripts/test_helper.js +1 -0
- data/spec/suite1/test/javascripts/testing_test.js +9 -0
- data/spec/suite1/test/javascripts/transactions_test.js +10 -0
- data/spec/suite1/test/javascripts/with_helper_test.js +4 -0
- data/spec/suite2/config/everqueen.rb +4 -0
- data/spec/suite2/public_html/foo.js +1 -0
- data/spec/suite2/test/awesome_test.js +7 -0
- data/spec/suite2/test/failing_test.js +4 -0
- data/spec/suite_spec.rb +19 -0
- data/spec/test_spec.rb +21 -0
- metadata +295 -0
data/lib/qunit/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
[QUnit](http://docs.jquery.com/QUnit) - A JavaScript Unit Testing framework.
|
2
|
+
================================
|
3
|
+
|
4
|
+
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery
|
5
|
+
project to test its code and plugins but is capable of testing any generic
|
6
|
+
JavaScript code (and even capable of testing JavaScript code on the server-side).
|
7
|
+
|
8
|
+
QUnit is especially useful for regression testing: Whenever a bug is reported,
|
9
|
+
write a test that asserts the existence of that particular bug. Then fix it and
|
10
|
+
commit both. Every time you work on the code again, run the tests. If the bug
|
11
|
+
comes up again - a regression - you'll spot it immediately and know how to fix
|
12
|
+
it, because you know what code you just changed.
|
13
|
+
|
14
|
+
Having good unit test coverage makes safe refactoring easy and cheap. You can
|
15
|
+
run the tests after each small refactoring step and always know what change
|
16
|
+
broke something.
|
17
|
+
|
18
|
+
QUnit is similar to other unit testing frameworks like JUnit, but makes use of
|
19
|
+
the features JavaScript provides and helps with testing code in the browser, eg.
|
20
|
+
with it's stop/start facilities for testing asynchronous code.
|
21
|
+
|
22
|
+
If you are interested in helping developing QUnit, you are in the right place.
|
23
|
+
For related discussions, visit the
|
24
|
+
[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing).
|
25
|
+
|
26
|
+
Planning for a qunitjs.com site and other testing tools related work now happens
|
27
|
+
on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage).
|
28
|
+
|
29
|
+
Releases
|
30
|
+
--------
|
31
|
+
|
32
|
+
Install git-extras and run `git changelog` to update History.md.
|
33
|
+
Update qunit/qunit.js|css to the release version, commit and tag, update them
|
34
|
+
again to the next version, commit and push commits and tags.
|
35
|
+
|
36
|
+
Put the 'v' in front of the tag (unlike the 1.1.0 release). Clean up the changelog,
|
37
|
+
removing merge commits or whitespace cleanups.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Canvas - A QUnit Addon For Testing Canvas Rendering
|
2
|
+
================================
|
3
|
+
|
4
|
+
This addon for QUnit adds a pixelEqual method that allows you to assert
|
5
|
+
individual pixel values in a given canvas.
|
6
|
+
|
7
|
+
Usage:
|
8
|
+
|
9
|
+
pixelEqual(canvas, x, y, r, g, b, a, message)
|
10
|
+
|
11
|
+
Where:
|
12
|
+
|
13
|
+
* canvas: Reference to a canvas element
|
14
|
+
* x, y: Coordinates of the pixel to test
|
15
|
+
* r, g, b, a: The color and opacity value of the pixel that you except
|
16
|
+
* message: Optional message, same as for other assertions
|
@@ -0,0 +1,76 @@
|
|
1
|
+
test("Canvas pixels", function () {
|
2
|
+
var canvas = document.getElementById('qunit-canvas'), context;
|
3
|
+
try {
|
4
|
+
context = canvas.getContext('2d');
|
5
|
+
} catch(e) {
|
6
|
+
// propably no canvas support, just exit
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
context.fillStyle = 'rgba(0, 0, 0, 0)';
|
10
|
+
context.fillRect(0, 0, 5, 5);
|
11
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
12
|
+
context.clearRect(0,0,5,5);
|
13
|
+
context.fillStyle = 'rgba(255, 0, 0, 0)';
|
14
|
+
context.fillRect(0, 0, 5, 5);
|
15
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
16
|
+
context.clearRect(0,0,5,5);
|
17
|
+
context.fillStyle = 'rgba(0, 255, 0, 0)';
|
18
|
+
context.fillRect(0, 0, 5, 5);
|
19
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
20
|
+
context.clearRect(0,0,5,5);
|
21
|
+
context.fillStyle = 'rgba(0, 0, 255, 0)';
|
22
|
+
context.fillRect(0, 0, 5, 5);
|
23
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 0);
|
24
|
+
context.clearRect(0,0,5,5);
|
25
|
+
|
26
|
+
context.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
27
|
+
context.fillRect(0, 0, 5, 5);
|
28
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 0, 127);
|
29
|
+
context.clearRect(0,0,5,5);
|
30
|
+
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
31
|
+
context.fillRect(0, 0, 5, 5);
|
32
|
+
QUnit.pixelEqual(canvas, 0, 0, 255, 0, 0, 127);
|
33
|
+
context.clearRect(0,0,5,5);
|
34
|
+
context.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
35
|
+
context.fillRect(0, 0, 5, 5);
|
36
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 255, 0, 127);
|
37
|
+
context.clearRect(0,0,5,5);
|
38
|
+
context.fillStyle = 'rgba(0, 0, 255, 0.5)';
|
39
|
+
context.fillRect(0, 0, 5, 5);
|
40
|
+
QUnit.pixelEqual(canvas, 0, 0, 0, 0, 255, 127);
|
41
|
+
context.clearRect(0,0,5,5);
|
42
|
+
|
43
|
+
context.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
44
|
+
context.fillRect(0, 0, 5, 5);
|
45
|
+
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 0, 127);
|
46
|
+
context.clearRect(0,0,5,5);
|
47
|
+
context.fillStyle = 'rgba(255, 0, 0, 0.5)';
|
48
|
+
context.fillRect(0, 0, 5, 5);
|
49
|
+
QUnit.pixelEqual(canvas, 2, 2, 255, 0, 0, 127);
|
50
|
+
context.clearRect(0,0,5,5);
|
51
|
+
context.fillStyle = 'rgba(0, 255, 0, 0.5)';
|
52
|
+
context.fillRect(0, 0, 5, 5);
|
53
|
+
QUnit.pixelEqual(canvas, 2, 2, 0, 255, 0, 127);
|
54
|
+
context.clearRect(0,0,5,5);
|
55
|
+
context.fillStyle = 'rgba(0, 0, 255, 0.5)';
|
56
|
+
context.fillRect(0, 0, 5, 5);
|
57
|
+
QUnit.pixelEqual(canvas, 2, 2, 0, 0, 255, 127);
|
58
|
+
context.clearRect(0,0,5,5);
|
59
|
+
|
60
|
+
context.fillStyle = 'rgba(0, 0, 0, 1)';
|
61
|
+
context.fillRect(0, 0, 5, 5);
|
62
|
+
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 0, 255);
|
63
|
+
context.clearRect(0,0,5,5);
|
64
|
+
context.fillStyle = 'rgba(255, 0, 0, 1)';
|
65
|
+
context.fillRect(0, 0, 5, 5);
|
66
|
+
QUnit.pixelEqual(canvas, 4, 4, 255, 0, 0, 255);
|
67
|
+
context.clearRect(0,0,5,5);
|
68
|
+
context.fillStyle = 'rgba(0, 255, 0, 1)';
|
69
|
+
context.fillRect(0, 0, 5, 5);
|
70
|
+
QUnit.pixelEqual(canvas, 4, 4, 0, 255, 0, 255);
|
71
|
+
context.clearRect(0,0,5,5);
|
72
|
+
context.fillStyle = 'rgba(0, 0, 255, 1)';
|
73
|
+
context.fillRect(0, 0, 5, 5);
|
74
|
+
QUnit.pixelEqual(canvas, 4, 4, 0, 0, 255, 255);
|
75
|
+
context.clearRect(0,0,5,5);
|
76
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>QUnit Test Suite - Canvas Addon</title>
|
6
|
+
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
7
|
+
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
8
|
+
<script type="text/javascript" src="qunit-canvas.js"></script>
|
9
|
+
<script type="text/javascript" src="canvas-test.js"></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h1 id="qunit-header">QUnit Test Suite - Canvas Addon</h1>
|
13
|
+
<h2 id="qunit-banner"></h2>
|
14
|
+
<div id="qunit-testrunner-toolbar"></div>
|
15
|
+
<h2 id="qunit-userAgent"></h2>
|
16
|
+
<ol id="qunit-tests"></ol>
|
17
|
+
<canvas id="qunit-canvas" width="5" height="5"></canvas>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
QUnit.extend( QUnit, {
|
2
|
+
pixelEqual: function(canvas, x, y, r, g, b, a, message) {
|
3
|
+
var actual = Array.prototype.slice.apply(canvas.getContext('2d').getImageData(x, y, 1, 1).data), expected = [r, g, b, a];
|
4
|
+
QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
|
5
|
+
}
|
6
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Close-Enough - A QUnit Addon For Number Approximations
|
2
|
+
================================
|
3
|
+
|
4
|
+
This addon for QUnit adds close and notClose assertion methods, to test that
|
5
|
+
numbers are close enough (or different enough) from an expected number, with
|
6
|
+
a specified accuracy.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
|
10
|
+
close(actual, expected, maxDifference, message)
|
11
|
+
notClose(actual, expected, minDifference, message)
|
12
|
+
|
13
|
+
Where:
|
14
|
+
|
15
|
+
* maxDifference: the maximum inclusive difference allowed between the actual and expected numbers
|
16
|
+
* minDifference: the minimum exclusive difference allowed between the actual and expected numbers
|
17
|
+
* actual, expected, message: The usual
|
@@ -0,0 +1,37 @@
|
|
1
|
+
test("Close Numbers", function () {
|
2
|
+
|
3
|
+
QUnit.close(7, 7, 0);
|
4
|
+
QUnit.close(7, 7.1, 0.1);
|
5
|
+
QUnit.close(7, 7.1, 0.2);
|
6
|
+
|
7
|
+
QUnit.close(3.141, Math.PI, 0.001);
|
8
|
+
QUnit.close(3.1, Math.PI, 0.1);
|
9
|
+
|
10
|
+
var halfPi = Math.PI / 2;
|
11
|
+
QUnit.close(halfPi, 1.57, 0.001);
|
12
|
+
|
13
|
+
var sqrt2 = Math.sqrt(2);
|
14
|
+
QUnit.close(sqrt2, 1.4142, 0.0001);
|
15
|
+
|
16
|
+
QUnit.close(Infinity, Infinity, 1);
|
17
|
+
|
18
|
+
});
|
19
|
+
|
20
|
+
test("Distant Numbers", function () {
|
21
|
+
|
22
|
+
QUnit.notClose(6, 7, 0);
|
23
|
+
QUnit.notClose(7, 7.2, 0.1);
|
24
|
+
QUnit.notClose(7, 7.2, 0.19999999999);
|
25
|
+
|
26
|
+
QUnit.notClose(3.141, Math.PI, 0.0001);
|
27
|
+
QUnit.notClose(3.1, Math.PI, 0.001);
|
28
|
+
|
29
|
+
var halfPi = Math.PI / 2;
|
30
|
+
QUnit.notClose(halfPi, 1.57, 0.0001);
|
31
|
+
|
32
|
+
var sqrt2 = Math.sqrt(2);
|
33
|
+
QUnit.notClose(sqrt2, 1.4142, 0.00001);
|
34
|
+
|
35
|
+
QUnit.notClose(Infinity, -Infinity, 5);
|
36
|
+
|
37
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>QUnit Test Suite - Close Enough Addon</title>
|
6
|
+
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
7
|
+
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
8
|
+
<script type="text/javascript" src="qunit-close-enough.js"></script>
|
9
|
+
<script type="text/javascript" src="close-enough-test.js"></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h1 id="qunit-header">QUnit Test Suite - Close Enough</h1>
|
13
|
+
<h2 id="qunit-banner"></h2>
|
14
|
+
<div id="qunit-testrunner-toolbar"></div>
|
15
|
+
<h2 id="qunit-userAgent"></h2>
|
16
|
+
<ol id="qunit-tests"></ol>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
QUnit.extend( QUnit, {
|
2
|
+
/**
|
3
|
+
* Checks that the first two arguments are equal, or are numbers close enough to be considered equal
|
4
|
+
* based on a specified maximum allowable difference.
|
5
|
+
*
|
6
|
+
* @example close(3.141, Math.PI, 0.001);
|
7
|
+
*
|
8
|
+
* @param Number actual
|
9
|
+
* @param Number expected
|
10
|
+
* @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
|
11
|
+
* @param String message (optional)
|
12
|
+
*/
|
13
|
+
close: function(actual, expected, maxDifference, message) {
|
14
|
+
var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
|
15
|
+
QUnit.push(passes, actual, expected, message);
|
16
|
+
},
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Checks that the first two arguments are numbers with differences greater than the specified
|
20
|
+
* minimum difference.
|
21
|
+
*
|
22
|
+
* @example notClose(3.1, Math.PI, 0.001);
|
23
|
+
*
|
24
|
+
* @param Number actual
|
25
|
+
* @param Number expected
|
26
|
+
* @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
|
27
|
+
* @param String message (optional)
|
28
|
+
*/
|
29
|
+
notClose: function(actual, expected, minDifference, message) {
|
30
|
+
QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message);
|
31
|
+
}
|
32
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Composite - A QUnit Addon For Running Multiple Test Files
|
2
|
+
================================
|
3
|
+
|
4
|
+
Composite is a QUnit addon that, when handed an array of files, will
|
5
|
+
open each of those files inside of an iframe, run the tests and
|
6
|
+
display the results as a single suite of QUnit tests.
|
7
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>QUnit SubsuiteRunner Test Suite</title>
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
8
|
+
<link rel="stylesheet" href="qunit-composite.css">
|
9
|
+
<script src="../../qunit/qunit.js"></script>
|
10
|
+
<script src="qunit-composite.js"></script>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
QUnit.testSuites([
|
14
|
+
"../../test/index.html",
|
15
|
+
"../canvas/canvas.html",
|
16
|
+
"../close-enough/close-enough.html",
|
17
|
+
"../step/step.html",
|
18
|
+
"composite-test.html"
|
19
|
+
]);
|
20
|
+
</script>
|
21
|
+
</head>
|
22
|
+
<body>
|
23
|
+
|
24
|
+
<h1 id="qunit-header">QUnit SubsuiteRunner Test Suite</h1>
|
25
|
+
<h2 id="qunit-banner"></h2>
|
26
|
+
<div id="qunit-testrunner-toolbar"></div>
|
27
|
+
<h2 id="qunit-userAgent"></h2>
|
28
|
+
<ol id="qunit-tests"></ol>
|
29
|
+
<div id="qunit-fixture">
|
30
|
+
|
31
|
+
</div>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title>QUnit Core Test Suite</title>
|
6
|
+
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
7
|
+
<script src="../../qunit/qunit.js"></script>
|
8
|
+
|
9
|
+
<script src="qunit-composite.js"></script>
|
10
|
+
<script src="composite-test.js"></script>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1 id="qunit-header">QUnit Core Test Suite</h1>
|
14
|
+
<h2 id="qunit-banner"></h2>
|
15
|
+
<div id="qunit-testrunner-toolbar"></div>
|
16
|
+
<h2 id="qunit-userAgent"></h2>
|
17
|
+
<ol id="qunit-tests"></ol>
|
18
|
+
<div id="qunit-fixture">test markup</div>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,159 @@
|
|
1
|
+
module( "testSuites tests", (function(){
|
2
|
+
var asyncTest = QUnit.asyncTest,
|
3
|
+
runSuite = QUnit.runSuite;
|
4
|
+
|
5
|
+
return {
|
6
|
+
setup: function(){
|
7
|
+
//proxy asyncTest and runSuite
|
8
|
+
QUnit.asyncTest = window.asyncTest = function( name, callback ){
|
9
|
+
ok( true, "asyncTestCalled for each suite" );
|
10
|
+
callback(); //don't acutally create tests, just call callback
|
11
|
+
};
|
12
|
+
QUnit.runSuite = window.runSuite = function(){
|
13
|
+
ok( true, "runSuite called for each suite" );
|
14
|
+
};
|
15
|
+
//ensure that subsuite's done doesn't run
|
16
|
+
this.oldDone = QUnit.done;
|
17
|
+
},
|
18
|
+
teardown: function(){
|
19
|
+
//restore
|
20
|
+
QUnit.asyncTest = window.asyncTest = asyncTest;
|
21
|
+
QUnit.runSuite = window.runSuite = runSuite;
|
22
|
+
QUnit.done = this.oldDone;
|
23
|
+
}
|
24
|
+
};
|
25
|
+
})());
|
26
|
+
|
27
|
+
test( "proper number of asyncTest and runSuite calls", function(){
|
28
|
+
expect( 6 );
|
29
|
+
QUnit.testSuites( ["one.html", "two.html", "three.html"] );
|
30
|
+
});
|
31
|
+
|
32
|
+
test( "done callback changed", function(){
|
33
|
+
QUnit.testSuites( ["dummy.html"] );
|
34
|
+
notEqual( this.oldDone, QUnit.done, "done callback should be set" );
|
35
|
+
});
|
36
|
+
|
37
|
+
module( "testStart tests", (function(){
|
38
|
+
var id = QUnit.id;
|
39
|
+
return {
|
40
|
+
setup: function(){
|
41
|
+
//proxy id
|
42
|
+
var fakeElem = this.fakeElem = document.createElement( "div" );
|
43
|
+
|
44
|
+
QUnit.id = function(){
|
45
|
+
return fakeElem;
|
46
|
+
}
|
47
|
+
},
|
48
|
+
teardown: function(){
|
49
|
+
QUnit.id = id;
|
50
|
+
}
|
51
|
+
};
|
52
|
+
})());
|
53
|
+
|
54
|
+
test( "running message printed", function(){
|
55
|
+
var hello = "hello world",
|
56
|
+
expected = "Running " + hello + "...<br> ";
|
57
|
+
QUnit.testStart( {name: hello} );
|
58
|
+
equal( this.fakeElem.innerHTML, expected, "innerHTML was set correctly by testStart" );
|
59
|
+
});
|
60
|
+
|
61
|
+
module( "testDone tests", (function(){
|
62
|
+
var id = QUnit.id;
|
63
|
+
return {
|
64
|
+
setup: function(){
|
65
|
+
//proxy id
|
66
|
+
var fakeElem = this.fakeElem = document.createElement( "div" );
|
67
|
+
fakeElem.appendChild( document.createElement( "ol" ) );
|
68
|
+
fakeElem.appendChild( document.createElement( "ol" ) );
|
69
|
+
QUnit.id = function(){
|
70
|
+
return fakeElem;
|
71
|
+
}
|
72
|
+
},
|
73
|
+
teardown: function(){
|
74
|
+
QUnit.id = id;
|
75
|
+
}
|
76
|
+
};
|
77
|
+
})());
|
78
|
+
|
79
|
+
test( "test expansions are hidden", function(){
|
80
|
+
QUnit.testDone();
|
81
|
+
equal( this.fakeElem.children[0].style.display, "none", "first ol display is none" );
|
82
|
+
equal( this.fakeElem.children[1].style.display, "none", "second ol display is none" );
|
83
|
+
});
|
84
|
+
|
85
|
+
test( "non-ol elements aren't hidden", function(){
|
86
|
+
this.fakeElem.appendChild( document.createElement( "span" ) );
|
87
|
+
|
88
|
+
QUnit.testDone();
|
89
|
+
notEqual( this.fakeElem.children[2].style.display, "none", "first ol display is none" );
|
90
|
+
});
|
91
|
+
|
92
|
+
module( "runSuite tests", (function(){
|
93
|
+
var getElementsByTagName = document.getElementsByTagName,
|
94
|
+
createElement = document.createElement,
|
95
|
+
runSuite = QUnit.runSuite;
|
96
|
+
|
97
|
+
return {
|
98
|
+
setup: function(){
|
99
|
+
//proxy getElementsByTagName and createElement
|
100
|
+
var setAttributeCall = this.setAttributeCall = {},
|
101
|
+
appendChildCall = this.appendChildCall = {called: 0},
|
102
|
+
iframeLoad = this.iframeLoad = {},
|
103
|
+
iframeQUnitObject = this.iframeQUnitObject = {},
|
104
|
+
fakeElement = {
|
105
|
+
appendChild: function(){appendChildCall.called++},
|
106
|
+
setAttribute: function(){setAttributeCall.args = arguments},
|
107
|
+
addEventListener: function( type, callback ){iframeLoad.callback = callback;},
|
108
|
+
contentWindow: {QUnit: iframeQUnitObject},
|
109
|
+
className: "",
|
110
|
+
};
|
111
|
+
|
112
|
+
document.getElementsByTagName = function(){
|
113
|
+
return [fakeElement];
|
114
|
+
};
|
115
|
+
document.createElement = function(){
|
116
|
+
return fakeElement;
|
117
|
+
}
|
118
|
+
|
119
|
+
},
|
120
|
+
teardown: function(){
|
121
|
+
document.getElementsByTagName = getElementsByTagName;
|
122
|
+
document.createElement = createElement;
|
123
|
+
//must restore even though we didn't proxy; the runner overwrites upon first call
|
124
|
+
QUnit.runSuite = runSuite;
|
125
|
+
}
|
126
|
+
};
|
127
|
+
})());
|
128
|
+
|
129
|
+
test( "runSuite different after first run", function(){
|
130
|
+
var before = QUnit.runSuite,
|
131
|
+
after;
|
132
|
+
QUnit.runSuite();
|
133
|
+
after = QUnit.runSuite;
|
134
|
+
notEqual( before, after, "runSuite changed after initial run" );
|
135
|
+
});
|
136
|
+
|
137
|
+
test( "iframe only created once", function(){
|
138
|
+
QUnit.runSuite();
|
139
|
+
equal( this.appendChildCall.called, 1, "append child called once" );
|
140
|
+
QUnit.runSuite();
|
141
|
+
equal( this.appendChildCall.called, 1, "append child only ever called once" );
|
142
|
+
});
|
143
|
+
|
144
|
+
test( "iframe's QUnit object is modified when iframe source loads", function(){
|
145
|
+
var before = this.iframeQUnitObject,
|
146
|
+
after;
|
147
|
+
QUnit.runSuite();
|
148
|
+
this.iframeLoad.callback();
|
149
|
+
notEqual( before, after, "iframe's qunit object is modified upon load");
|
150
|
+
});
|
151
|
+
|
152
|
+
test( "iframe src set to suite passed", function(){
|
153
|
+
var pages = ["testing.html", "subsuiteRunner.html"];
|
154
|
+
QUnit.runSuite( pages[0] );
|
155
|
+
equal( this.setAttributeCall.args[0], "src", "src attribute set" );
|
156
|
+
equal( this.setAttributeCall.args[1], pages[0], "src attribute set" );
|
157
|
+
QUnit.runSuite( pages[1] );
|
158
|
+
equal( this.setAttributeCall.args[1], pages[1], "src attribute set" );
|
159
|
+
});
|