vendor/node_modules/mocha/mocha.js in stylus-source-0.27.0 vs vendor/node_modules/mocha/mocha.js in stylus-source-0.27.1
- old
+ new
@@ -78,11 +78,11 @@
}
/**
* Event emitter constructor.
*
- * @api public.
+ * @api public
*/
function EventEmitter(){};
/**
@@ -186,11 +186,11 @@
};
/**
* Gets all listeners for a certain event.
*
- * @api publci
+ * @api public
*/
EventEmitter.prototype.listeners = function (name) {
if (!this.$events) {
this.$events = {};
@@ -558,11 +558,11 @@
* Describe a "suite" with the given `title`
* and callback `fn` containing nested suites
* and/or tests.
*/
- context.describe = function(title, fn){
+ context.describe = context.context = function(title, fn){
var suite = Suite.create(suites[0], title);
suites.unshift(suite);
fn();
suites.shift();
};
@@ -868,11 +868,11 @@
/**
* Library version.
*/
-exports.version = '1.0.2';
+exports.version = '1.0.3';
/**
* Expose internals.
*/
@@ -906,19 +906,21 @@
* - `ui` name "bdd", "tdd", "exports" etc
* - `reporter` reporter instance, defaults to `mocha.reporters.Dot`
* - `globals` array of accepted globals
* - `timeout` timeout in milliseconds
* - `ignoreLeaks` ignore global leaks
+ * - `grep` string or regexp to filter tests with
*
* @param {Object} options
* @api public
*/
function Mocha(options) {
options = options || {};
this.files = [];
this.options = options;
+ this.grep(options.grep);
this.suite = new exports.Suite('', new exports.Context);
this.ui(options.ui);
this.reporter(options.reporter);
if (options.timeout) this.suite.timeout(options.timeout);
}
@@ -1002,10 +1004,25 @@
}
});
};
/**
+ * Add regexp to grep for to the options object
+ *
+ * @param {RegExp} or {String} re
+ * @return {Mocha}
+ * @api public
+ */
+
+Mocha.prototype.grep = function(re){
+ this.options.grep = 'string' == typeof re
+ ? new RegExp(re)
+ : re;
+ return this;
+};
+
+/**
* Run tests and invoke `fn()` when complete.
*
* @param {Function} fn
* @return {Runner}
* @api public
@@ -1021,11 +1038,10 @@
if (options.grep) runner.grep(options.grep);
if (options.globals) runner.globals(options.globals);
if (options.growl) this.growl(runner, reporter);
return runner.run(fn);
};
-
}); // module: mocha.js
require.register("reporters/base.js", function(module, exports, require){
/**
@@ -1034,10 +1050,20 @@
var tty = require('browser/tty')
, diff = require('browser/diff');
/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
+/**
* Check if both stdio streams are associated with a tty.
*/
var isatty = tty.isatty(1) && tty.isatty(2);
@@ -1349,11 +1375,11 @@
* @api private
*/
function errorDiff(err, type) {
return diff['diff' + type](err.actual, err.expected).map(function(str){
- if (str.value == '\n') str.value = '<newline>\n';
+ if (/^(\n+)$/.test(str.value)) str.value = Array(++RegExp.$1.length).join('<newline>');
if (str.added) return colorLines('diff added', str.value);
if (str.removed) return colorLines('diff removed', str.value);
return str.value;
}).join('');
}
@@ -1576,10 +1602,20 @@
, utils = require('../utils')
, Progress = require('../browser/progress')
, escape = utils.escape;
/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
+/**
* Expose `Doc`.
*/
exports = module.exports = HTML;
@@ -1612,11 +1648,12 @@
, items = stat.getElementsByTagName('li')
, passes = items[1].getElementsByTagName('em')[0]
, failures = items[2].getElementsByTagName('em')[0]
, duration = items[3].getElementsByTagName('em')[0]
, canvas = stat.getElementsByTagName('canvas')[0]
- , stack = [root]
+ , report = fragment('<ul id="report"></ul>')
+ , stack = [report]
, progress
, ctx
if (canvas.getContext) {
ctx = canvas.getContext('2d');
@@ -1624,22 +1661,24 @@
}
if (!root) return error('#mocha div missing, add it to your document');
root.appendChild(stat);
+ root.appendChild(report);
if (progress) progress.size(40);
runner.on('suite', function(suite){
if (suite.root) return;
// suite
- var el = fragment('<div class="suite"><h1>%s</h1></div>', suite.title);
+ var url = location.origin + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle());
+ var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, suite.title);
// container
stack[0].appendChild(el);
- stack.unshift(document.createElement('div'));
+ stack.unshift(document.createElement('ul'));
el.appendChild(stack[0]);
});
runner.on('suite end', function(suite){
if (suite.root) return;
@@ -1661,15 +1700,15 @@
text(failures, stats.failures);
text(duration, (ms / 1000).toFixed(2));
// test
if ('passed' == test.state) {
- var el = fragment('<div class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></div>', test.speed, test.title, test.duration);
+ var el = fragment('<li class="test pass %e"><h2>%e<span class="duration">%ems</span></h2></li>', test.speed, test.title, test.duration);
} else if (test.pending) {
- var el = fragment('<div class="test pass pending"><h2>%e</h2></div>', test.title);
+ var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
} else {
- var el = fragment('<div class="test fail"><h2>%e</h2></div>', test.title);
+ var el = fragment('<li class="test fail"><h2>%e</h2></li>', test.title);
var str = test.err.stack || test.err.toString();
// FF / Opera do not add the message
if (!~str.indexOf(test.err.message)) {
str = test.err.message + '\n' + str;
@@ -2700,37 +2739,47 @@
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
- console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle()));
+ console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
runner.on('fail', function(test, err) {
- console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message));
+ console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']");
});
runner.on('pending', function(test) {
- console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle()));
+ console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']");
});
runner.on('test end', function(test) {
- console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration);
+ console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']");
});
runner.on('end', function() {
- console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='%s']", stats.duration);
+ console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']");
});
}
/**
* Escape the given `str`.
*/
function escape(str) {
- return str.replace(/'/g, "|'");
+ return str
+ .replace(/\|/g, "||")
+ .replace(/\n/g, "|n")
+ .replace(/\r/g, "|r")
+ .replace(/\[/g, "|[")
+ .replace(/\]/g, "|]")
+ .replace(/\u0085/g, "|x")
+ .replace(/\u2028/g, "|l")
+ .replace(/\u2029/g, "|p")
+ .replace(/'/g, "|'");
}
+
}); // module: reporters/teamcity.js
require.register("reporters/xunit.js", function(module, exports, require){
/**
@@ -2740,10 +2789,20 @@
var Base = require('./base')
, utils = require('../utils')
, escape = utils.escape;
/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
+/**
* Expose `XUnit`.
*/
exports = module.exports = XUnit;
@@ -2846,10 +2905,20 @@
var EventEmitter = require('browser/events').EventEmitter
, debug = require('browser/debug')('runnable');
/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
+/**
* Expose `Runnable`.
*/
module.exports = Runnable;
@@ -3149,10 +3218,13 @@
*/
Runner.prototype.fail = function(test, err){
++this.failures;
test.state = 'failed';
+ if ('string' == typeof err) {
+ err = new Error('the string "' + err + '" was thrown, throw an Error :)');
+ }
this.emit('fail', test, err);
};
/**
* Fail the given `hook` with `err`.
@@ -3976,16 +4048,29 @@
/**
* Compute a slug from the given `str`.
*
* @param {String} str
* @return {String}
+ * @api private
*/
exports.slug = function(str){
return str
.toLowerCase()
.replace(/ +/g, '-')
.replace(/[^-\w]/g, '');
+};
+
+/**
+ * Escape regular expression characters in `str`.
+ *
+ * @param {String} str
+ * @return {String}
+ * @api private
+ */
+
+exports.escapeRegexp = function(str){
+ return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
};
}); // module: utils.js
/**
* Node shims.
*
\ No newline at end of file