Skip to content

Commit

Permalink
chore(internal): apply pr feedback on #284
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Aug 14, 2020
1 parent 22ea958 commit 2333a91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 15 additions & 5 deletions packages/mocha/src/flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function isSkipped({ flags, total, isDeactivated }) {

function flaggedIt(total, isDeactivated) {
return it => {
return function flaggedTest(stringOrObject, callback) {
return function flaggedIt(stringOrObject, callback) {
let { name, flags } = infoFor(stringOrObject);

if (!isDeactivated) {
Expand All @@ -74,7 +74,7 @@ const mochaAfterEach = global.afterEach;

function flaggedDescribe(total, isDeactivated) {
return (describe) => {
return function _flaggedDescribe(stringOrObjectOrCallback, callback) {
return function flaggedDescribe(stringOrObjectOrCallback, callback) {
let { name, flags } = infoFor(stringOrObjectOrCallback);

if (!isDeactivated) {
Expand All @@ -85,7 +85,13 @@ function flaggedDescribe(total, isDeactivated) {
callback = stringOrObjectOrCallback;
}

describe(name, function() {
let describeArgs = [];

if (name) {
describeArgs.push(name);
}

function anonymousDescribe() {
function before(beforeCallback) {
return mochaBefore(function (...args) {
if (isSkipped({ flags, total, isDeactivated })) {
Expand Down Expand Up @@ -131,7 +137,12 @@ function flaggedDescribe(total, isDeactivated) {
}

callback.apply(this, [{ beforeEach, afterEach, before, after }]);
});

}

describeArgs.push(anonymousDescribe);

describe(...describeArgs);
};
};
}
Expand All @@ -153,7 +164,6 @@ function createDescribe(describe, flags, isDeactivated) {
}

module.exports = {
create: createIt,
createIt: createIt,
createDescribe,
};
1 change: 0 additions & 1 deletion packages/mocha/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ module.exports = {
createRolesHelper: require('./role').create,
failureArtifacts: require('./failure-artifacts'),
createFailureArtifactsHelpers: require('./failure-artifacts').create,
createFlaggedTest: createFlaggedIt,
createFlaggedIt: createFlaggedIt,
createFlaggedDescribe,
};

0 comments on commit 2333a91

Please sign in to comment.