2014-01-24 13:24:23 +04:00
|
|
|
|
/*
|
|
|
|
|
* grunt-contrib-qunit
|
|
|
|
|
* http://gruntjs.com/
|
|
|
|
|
*
|
2014-04-17 22:36:17 +04:00
|
|
|
|
* Copyright (c) 2013 'Cowboy' Ben Alman, contributors
|
2014-01-24 13:24:23 +04:00
|
|
|
|
* Licensed under the MIT license.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*global QUnit:true, alert:true*/
|
|
|
|
|
(function () {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// Don't re-order tests.
|
|
|
|
|
QUnit.config.reorder = false
|
|
|
|
|
// Run tests serially, not in parallel.
|
|
|
|
|
QUnit.config.autorun = false
|
|
|
|
|
|
|
|
|
|
// Send messages to the parent PhantomJS process via alert! Good times!!
|
|
|
|
|
function sendMessage() {
|
|
|
|
|
var args = [].slice.call(arguments)
|
|
|
|
|
alert(JSON.stringify(args))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// These methods connect QUnit to PhantomJS.
|
2014-04-17 22:36:17 +04:00
|
|
|
|
QUnit.log = function (obj) {
|
2014-01-24 13:24:23 +04:00
|
|
|
|
// What is this I don’t even
|
|
|
|
|
if (obj.message === '[object Object], undefined:undefined') { return }
|
|
|
|
|
// Parse some stuff before sending it.
|
|
|
|
|
var actual = QUnit.jsDump.parse(obj.actual)
|
|
|
|
|
var expected = QUnit.jsDump.parse(obj.expected)
|
|
|
|
|
// Send it.
|
|
|
|
|
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source)
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
|
QUnit.testStart = function (obj) {
|
2014-01-24 13:24:23 +04:00
|
|
|
|
sendMessage('qunit.testStart', obj.name)
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
|
QUnit.testDone = function (obj) {
|
2014-01-24 13:24:23 +04:00
|
|
|
|
sendMessage('qunit.testDone', obj.name, obj.failed, obj.passed, obj.total)
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-17 22:36:17 +04:00
|
|
|
|
QUnit.moduleStart = function (obj) {
|
2014-01-24 13:24:23 +04:00
|
|
|
|
sendMessage('qunit.moduleStart', obj.name)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUnit.begin = function () {
|
|
|
|
|
sendMessage('qunit.begin')
|
2014-04-17 22:36:17 +04:00
|
|
|
|
console.log('Starting test suite')
|
|
|
|
|
console.log('================================================\n')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUnit.moduleDone = function (opts) {
|
|
|
|
|
if (opts.failed === 0) {
|
2014-04-17 22:36:17 +04:00
|
|
|
|
console.log('\r\u2714 All tests passed in "' + opts.name + '" module')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
} else {
|
2014-04-17 22:36:17 +04:00
|
|
|
|
console.log('\u2716 ' + opts.failed + ' tests failed in "' + opts.name + '" module')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
}
|
|
|
|
|
sendMessage('qunit.moduleDone', opts.name, opts.failed, opts.passed, opts.total)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUnit.done = function (opts) {
|
2014-04-17 22:36:17 +04:00
|
|
|
|
console.log('\n================================================')
|
|
|
|
|
console.log('Tests completed in ' + opts.runtime + ' milliseconds')
|
|
|
|
|
console.log(opts.passed + ' tests of ' + opts.total + ' passed, ' + opts.failed + ' failed.')
|
2014-01-24 13:24:23 +04:00
|
|
|
|
sendMessage('qunit.done', opts.failed, opts.passed, opts.total, opts.runtime)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}())
|