Skip to content

Commit

Permalink
Use positive logic for code block skip test.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjeffburke committed Jun 28, 2020
1 parent 2073a4e commit 94b9be0
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/convertMarkdownToMocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ var { Markdown } = require('evaldown');

var resolvedPathToEvaldown = require.resolve('evaldown');

function checkCodeBlockSkipped(codeBlock) {
function isCodeBlockThatShouldBeRun(codeBlock) {
const { lang, flags } = codeBlock;

if (!(lang === 'javascript' || lang === 'output')) {
return true;
} else if (lang === 'javascript' && !flags.evaluate) {
return true;
}

return false;
return lang === 'output' || (lang === 'javascript' && flags.evaluate);
}

function parseFunctionBody(fn) {
Expand Down Expand Up @@ -113,9 +107,9 @@ module.exports = function (mdSrc, filePath) {
codeBlock.lineNumber + 1
}:1)`;

let isSkipped = false;
let itExpressionStatement;
if ((isSkipped = checkCodeBlockSkipped(codeBlock))) {
var isSkipped = false;
var itExpressionStatement;
if ((isSkipped = !isCodeBlockThatShouldBeRun(codeBlock))) {
/* eslint-disable */
itExpressionStatement = parseFunctionBody(
/* istanbul ignore next */
Expand Down

0 comments on commit 94b9be0

Please sign in to comment.