Skip to content

Commit 00f575a

Browse files
committed
Add QUnit testing during Grunt build
- Updated QUnit to 1.12 - Use root copies of toaster for the tests page - Remove toastr copies under test - Use the bower version of jQuery
1 parent e5dee6b commit 00f575a

8 files changed

+1646
-1338
lines changed

Gruntfile.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ module.exports = function(grunt) {
2222
"toastr.min.js": "toastr.js"
2323
}
2424
}
25-
}
25+
},
26+
qunit: {
27+
all: ['tests/toastr-tests.html']
28+
}
2629
});
2730

2831
grunt.loadNpmTasks('grunt-contrib-less');
2932
grunt.loadNpmTasks('grunt-contrib-uglify');
33+
grunt.loadNpmTasks('grunt-contrib-qunit');
3034

31-
grunt.registerTask('default', ['less', 'uglify']);
35+
grunt.registerTask('default', ['less', 'qunit', 'uglify']);
3236
};

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
],
3030
"devDependencies": {
3131
"grunt-contrib-uglify": "~0.2.2",
32-
"grunt-contrib-less": "~0.6.4"
32+
"grunt-contrib-less": "~0.6.4",
33+
"grunt-contrib-qunit": "~0.2.2"
3334
}
3435
}

tests/qunit/qunit.css

+45-26
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
2-
* QUnit - A JavaScript Unit Testing Framework
2+
* QUnit v1.12.0 - A JavaScript Unit Testing Framework
33
*
4-
* http://docs.jquery.com/QUnit
4+
* http://qunitjs.com
55
*
6-
* Copyright (c) 2011 John Resig, Jörn Zaefferer
7-
* Dual licensed under the MIT (MIT-LICENSE.txt)
8-
* or GPL (GPL-LICENSE.txt) licenses.
6+
* Copyright 2012 jQuery Foundation and other contributors
7+
* Released under the MIT license.
8+
* http://jquery.org/license
99
*/
1010

1111
/** Font Family and Sizes */
@@ -20,7 +20,7 @@
2020

2121
/** Resets */
2222

23-
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
23+
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
2424
margin: 0;
2525
padding: 0;
2626
}
@@ -38,10 +38,10 @@
3838
line-height: 1em;
3939
font-weight: normal;
4040

41-
border-radius: 15px 15px 0 0;
42-
-moz-border-radius: 15px 15px 0 0;
43-
-webkit-border-top-right-radius: 15px;
44-
-webkit-border-top-left-radius: 15px;
41+
border-radius: 5px 5px 0 0;
42+
-moz-border-radius: 5px 5px 0 0;
43+
-webkit-border-top-right-radius: 5px;
44+
-webkit-border-top-left-radius: 5px;
4545
}
4646

4747
#qunit-header a {
@@ -54,6 +54,11 @@
5454
color: #fff;
5555
}
5656

57+
#qunit-testrunner-toolbar label {
58+
display: inline-block;
59+
padding: 0 .5em 0 .1em;
60+
}
61+
5762
#qunit-banner {
5863
height: 5px;
5964
}
@@ -62,6 +67,7 @@
6267
padding: 0.5em 0 0.5em 2em;
6368
color: #5E740B;
6469
background-color: #eee;
70+
overflow: hidden;
6571
}
6672

6773
#qunit-userAgent {
@@ -71,6 +77,9 @@
7177
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
7278
}
7379

80+
#qunit-modulefilter-container {
81+
float: right;
82+
}
7483

7584
/** Tests: Pass/Fail */
7685

@@ -102,19 +111,24 @@
102111
color: #000;
103112
}
104113

105-
#qunit-tests ol {
114+
#qunit-tests li .runtime {
115+
float: right;
116+
font-size: smaller;
117+
}
118+
119+
.qunit-assert-list {
106120
margin-top: 0.5em;
107121
padding: 0.5em;
108122

109123
background-color: #fff;
110124

111-
border-radius: 15px;
112-
-moz-border-radius: 15px;
113-
-webkit-border-radius: 15px;
125+
border-radius: 5px;
126+
-moz-border-radius: 5px;
127+
-webkit-border-radius: 5px;
128+
}
114129

115-
box-shadow: inset 0px 2px 13px #999;
116-
-moz-box-shadow: inset 0px 2px 13px #999;
117-
-webkit-box-shadow: inset 0px 2px 13px #999;
130+
.qunit-collapsed {
131+
display: none;
118132
}
119133

120134
#qunit-tests table {
@@ -157,8 +171,7 @@
157171
#qunit-tests b.failed { color: #710909; }
158172

159173
#qunit-tests li li {
160-
margin: 0.5em;
161-
padding: 0.4em 0.5em 0.4em 0.5em;
174+
padding: 5px;
162175
background-color: #fff;
163176
border-bottom: none;
164177
list-style-position: inside;
@@ -167,9 +180,9 @@
167180
/*** Passing Styles */
168181

169182
#qunit-tests li li.pass {
170-
color: #5E740B;
183+
color: #3c510c;
171184
background-color: #fff;
172-
border-left: 26px solid #C6E746;
185+
border-left: 10px solid #C6E746;
173186
}
174187

175188
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
@@ -185,14 +198,15 @@
185198
#qunit-tests li li.fail {
186199
color: #710909;
187200
background-color: #fff;
188-
border-left: 26px solid #EE5757;
201+
border-left: 10px solid #EE5757;
202+
white-space: pre;
189203
}
190204

191205
#qunit-tests > li:last-child {
192-
border-radius: 0 0 15px 15px;
193-
-moz-border-radius: 0 0 15px 15px;
194-
-webkit-border-bottom-right-radius: 15px;
195-
-webkit-border-bottom-left-radius: 15px;
206+
border-radius: 0 0 5px 5px;
207+
-moz-border-radius: 0 0 5px 5px;
208+
-webkit-border-bottom-right-radius: 5px;
209+
-webkit-border-bottom-left-radius: 5px;
196210
}
197211

198212
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
@@ -215,11 +229,16 @@
215229

216230
border-bottom: 1px solid white;
217231
}
232+
#qunit-testresult .module-name {
233+
font-weight: bold;
234+
}
218235

219236
/** Fixture */
220237

221238
#qunit-fixture {
222239
position: absolute;
223240
top: -10000px;
224241
left: -10000px;
242+
width: 1000px;
243+
height: 1000px;
225244
}

0 commit comments

Comments
 (0)