Skip to content

Commit

Permalink
chore: reenable linting as part of test script
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Oct 15, 2019
1 parent 6fc750e commit 3fe378a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/core/topologies/shared.js
Expand Up @@ -458,7 +458,7 @@ function getMMAPError(err) {
return newErr;
}

module.exports. SessionMixins = SessionMixins;
module.exports.SessionMixins = SessionMixins;
module.exports.resolveClusterTime = resolveClusterTime;
module.exports.inquireServerState = inquireServerState;
module.exports.getTopologyType = getTopologyType;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -62,7 +62,7 @@
},
"scripts": {
"atlas": "node ./test/atlas_connectivity_tests.js",
"test": "mocha --recursive test/functional test/unit test/core",
"test": "npm run lint && mocha --recursive test/functional test/unit test/core",
"coverage": "istanbul cover mongodb-test-runner -- -t 60000 test/core test/unit test/functional",
"lint": "eslint lib test",
"format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'",
Expand Down
2 changes: 1 addition & 1 deletion test/core/functional/srv_polling_tests.js
Expand Up @@ -69,7 +69,7 @@ describe('Mongos SRV Polling', function() {
context.sinon.stub(poller, 'parentDomainMismatch');
}

describe('success', function(done) {
describe('success', function() {
it('should emit event, disable haMode, and schedule another poll', function(done) {
const records = [srvRecord('jalad.tanagra.com'), srvRecord('thebeast.tanagra.com')];
const poller = new SrvPoller({ srvHost: SRV_HOST });
Expand Down
38 changes: 26 additions & 12 deletions test/runner/metadata_ui.js
Expand Up @@ -4,8 +4,8 @@
* Module dependencies.
*/
var Mocha = require('mocha'),
Suite = require('mocha/lib/suite'),
Test = require('mocha/lib/test');
Suite = require('mocha/lib/suite'),
Test = require('mocha/lib/test');

/**
* This UI is identical to the BDD interface, but with the addition of
Expand Down Expand Up @@ -33,9 +33,11 @@ module.exports = Mocha.interfaces.metadata_ui = function(suite) {
throw new Error('First argument must be a string.');
}
testData.title = args[0];
if (args.length === 1) { // Only a title, to mark a pending test
if (args.length === 1) {
// Only a title, to mark a pending test
return testData;
} else if (args.length === 2) { // No metadata, describe(title, fn), or metadata as an object, describe(title, obj)
} else if (args.length === 2) {
// No metadata, describe(title, fn), or metadata as an object, describe(title, obj)
if (typeof args[1] === 'object') {
if (args[1].metadata && typeof args[1].metadata === 'object') {
testData.metadata = args[1].metadata;
Expand All @@ -44,23 +46,31 @@ module.exports = Mocha.interfaces.metadata_ui = function(suite) {
} else if (args[1].test && typeof args[1].test === 'function') {
testData.fn = args[1].test;
} else {
throw new Error('If passing an object as the second parameter, it must be of the form { <object>, <function> }');
throw new Error(
'If passing an object as the second parameter, it must be of the form { <object>, <function> }'
);
}
} else {
throw new Error('If passing an object as the second parameter, it must be of the form { <object>, <function> }');
throw new Error(
'If passing an object as the second parameter, it must be of the form { <object>, <function> }'
);
}
} else if (typeof args[1] === 'function') {
testData.fn = args[1];
} else {
throw new Error('Incorrect usage. Parameters must be either "<string>, { <object>, <function> }" or "<string>, <function>"');
throw new Error(
'Incorrect usage. Parameters must be either "<string>, { <object>, <function> }" or "<string>, <function>"'
);
}
} else if (args.length === 3) { // Metadata as a param: describe(title, meta, fn)
if (args[1] && typeof args[1] === 'object'
&& args[2] && typeof args[2] === 'function') {
} else if (args.length === 3) {
// Metadata as a param: describe(title, meta, fn)
if (args[1] && typeof args[1] === 'object' && args[2] && typeof args[2] === 'function') {
testData.metadata = args[1];
testData.fn = args[2];
} else {
throw new Error('If passing three parameters, they must be of the form "<string>, <object>, <function>"');
throw new Error(
'If passing three parameters, they must be of the form "<string>, <object>, <function>"'
);
}
} else if (args.length > 3) {
throw new Error('Too many arguments passed.');
Expand Down Expand Up @@ -91,7 +101,11 @@ module.exports = Mocha.interfaces.metadata_ui = function(suite) {
testData.fn.call(newSuite);
suites.shift();
} else if (typeof testData.fn === 'undefined' && !newSuite.pending) {
throw new Error('Suite "' + newSuite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
throw new Error(
'Suite "' +
newSuite.fullTitle() +
'" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'
);
}

return newSuite;
Expand Down

0 comments on commit 3fe378a

Please sign in to comment.