Skip to content

Commit

Permalink
style: Make prettier happy
Browse files Browse the repository at this point in the history
Formatting changes required to consider commit. In test specs, combined `return done(err)`.
  • Loading branch information
plroebuck committed Nov 4, 2018
1 parent ce03b99 commit 0fd5585
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
11 changes: 9 additions & 2 deletions lib/interfaces/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module.exports = function(suites, context, mocha) {

/**
* Creates a suite.
*
* @param {Object} opts Options
* @param {string} opts.title Title of Suite
* @param {Function} [opts.fn] Suite Function (not always applicable)
Expand All @@ -112,14 +113,20 @@ module.exports = function(suites, context, mocha) {
if (typeof opts.fn === 'function') {
var result = opts.fn.call(suite);
if (typeof result !== 'undefined') {
utils.deprecate('Deprecation Warning: Suites do not support a return value;' + opts.title + ' returned :' + result);
utils.deprecate(
'Deprecation Warning: Suites do not support a return value;' +
opts.title +
' returned :' +
result
);
}
suites.shift();
} else if (typeof opts.fn === 'undefined' && !suite.pending) {
throw new Error(
'Suite "' +
suite.fullTitle() +
'" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'
'" was defined but no callback was supplied. ' +
'Supply a callback or explicitly skip the suite.'
);
} else if (!opts.fn && suite.pending) {
suites.shift();
Expand Down
16 changes: 11 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ exports.getError = function(err) {
*
* @param {string} msg
*/
exports.deprecate = function (msg) {
exports.deprecate = function(msg) {
msg = String(msg);
if (seenDeprecationMsg.hasOwnProperty(msg)) {
return;
Expand All @@ -601,10 +601,16 @@ exports.deprecate = function (msg) {
var seenDeprecationMsg = {};

var doDeprecationWarning = process.emitWarning
// Node.js v6+
? function (msg) { process.emitWarning(msg, 'DeprecationWarning'); }
// Everything else
: function (msg) { process.nextTick(() => console.warn(msg)); };
? function(msg) {
// Node.js v6+
process.emitWarning(msg, 'DeprecationWarning');
}
: function(msg) {
// Everything else
process.nextTick(function() {
console.warn(msg);
});
};

/**
* @summary
Expand Down
9 changes: 4 additions & 5 deletions test/integration/deprecate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ var assert = require('assert');
var run = require('./helpers').runMocha;
var args = [];

describe.only('utils.deprecate test', function () {
it('should print unique deprecation only once', function (done) {
run('deprecate.fixture.js', args, function (err, res) {
describe.only('utils.deprecate test', function() {
it('should print unique deprecation only once', function(done) {
run('deprecate.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
console.trace(res);
var result = res.output.match(/deprecated thing/g) || [];
Expand Down
18 changes: 7 additions & 11 deletions test/integration/suite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ describe('suite w/no callback', function() {
it('should throw a helpful error message when a callback for suite is not supplied', function(done) {
run('suite/suite-no-callback.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
var result = res.output.match(/no callback was supplied/) || [];
assert.equal(result.length, 1);
Expand All @@ -24,8 +23,7 @@ describe('skipped suite w/no callback', function() {
it('should not throw an error when a callback for skipped suite is not supplied', function(done) {
run('suite/suite-skipped-no-callback.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
var pattern = new RegExp('Error', 'g');
var result = res.output.match(pattern) || [];
Expand All @@ -40,8 +38,7 @@ describe('skipped suite w/ callback', function() {
it('should not throw an error when a callback for skipped suite is supplied', function(done) {
run('suite/suite-skipped-callback.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
var pattern = new RegExp('Error', 'g');
var result = res.output.match(pattern) || [];
Expand All @@ -51,13 +48,12 @@ describe('skipped suite w/ callback', function() {
});
});

describe('suite returning a value', function () {
describe('suite returning a value', function() {
this.timeout(2000);
it('should give a deprecation warning for suite callback returning a value', function (done) {
run('suite/suite-returning-value.fixture.js', args, function (err, res) {
it('should give a deprecation warning for suite callback returning a value', function(done) {
run('suite/suite-returning-value.fixture.js', args, function(err, res) {
if (err) {
done(err);
return;
return done(err);
}
var pattern = new RegExp('Deprecation Warning', 'g');
var result = res.output.match(pattern) || [];
Expand Down

0 comments on commit 0fd5585

Please sign in to comment.