Ignore some things in coverage (#2741)

- If statements for old deprecated stuff.
- "This should never happen" (and never happens in the tests) code paths.
master
Simon Lydell 2017-09-03 22:40:44 +02:00 committed by Christopher Chedeau
parent 368522cf33
commit 133303f47a
10 changed files with 18 additions and 0 deletions

View File

@ -41,6 +41,7 @@ function getParserOption(argv) {
}
// For backward compatibility. Deprecated in 0.0.10
/* istanbul ignore if */
if (argv["flow-parser"]) {
console.warn("`--flow-parser` is deprecated. Use `--parser flow` instead.");
return "flow";

View File

@ -121,6 +121,7 @@ function decorateComment(node, comment, text) {
continue;
}
/* istanbul ignore next */
throw new Error("Comment location overlaps with node location");
}
@ -226,6 +227,7 @@ function attach(comments, ast, text) {
addDanglingComment(enclosingNode, comment);
} else {
// There are no nodes, let's attach it to the root of the ast
/* istanbul ignore next */
addDanglingComment(ast, comment);
}
} else if (util.hasNewline(text, locEnd(comment))) {
@ -278,6 +280,7 @@ function attach(comments, ast, text) {
addDanglingComment(enclosingNode, comment);
} else {
// There are no nodes, let's attach it to the root of the ast
/* istanbul ignore next */
addDanglingComment(ast, comment);
}
} else {
@ -317,6 +320,7 @@ function attach(comments, ast, text) {
addDanglingComment(enclosingNode, comment);
} else {
// There are no nodes, let's attach it to the root of the ast
/* istanbul ignore next */
addDanglingComment(ast, comment);
}
}
@ -887,6 +891,7 @@ function findExpressionIndexForComment(quasis, comment) {
// We haven't found it, it probably means that some of the locations are off.
// Let's just return the first one.
/* istanbul ignore next */
return 0;
}

View File

@ -1,6 +1,7 @@
"use strict";
function assertDoc(val) {
/* istanbul ignore if */
if (
!(typeof val === "string" || (val != null && typeof val.type === "string"))
) {

View File

@ -19,6 +19,7 @@ FastPath.prototype.getName = function getName() {
}
// Since the name is always a string, null is a safe sentinel value to
// return if we do not know the name of the (root) value.
/* istanbul ignore next */
return null;
};

View File

@ -178,6 +178,7 @@ function transformCssDoc(quasisDoc, parent) {
? parent.path.map(parent.print, "expressions")
: [];
const newDoc = replacePlaceholders(quasisDoc, expressionDocs);
/* istanbul ignore if */
if (!newDoc) {
throw new Error("Couldn't insert all the expressions");
}

View File

@ -45,6 +45,7 @@ function normalize(options) {
normalized.trailingComma = "none";
}
/* istanbul ignore if */
if (typeof normalized.trailingComma === "boolean") {
// Support a deprecated boolean type for the trailing comma config
// for a few versions. This code can be removed later.
@ -68,6 +69,7 @@ function normalize(options) {
normalized.parser = parserBackup;
// For backward compatibility. Deprecated in 0.0.10
/* istanbul ignore if */
if ("useFlowParser" in normalized) {
normalized.parser = normalized.useFlowParser ? "flow" : "babylon";
delete normalized.useFlowParser;

View File

@ -37,9 +37,11 @@ function resolveParseFunction(opts) {
try {
return eval("require")(path.resolve(process.cwd(), opts.parser));
} catch (err) {
/* istanbul ignore next */
throw new Error(`Couldn't resolve parser "${opts.parser}"`);
}
}
/* istanbul ignore next */
return parsers.babylon;
}
@ -60,6 +62,7 @@ function parse(text, opts) {
throw error;
}
/* istanbul ignore next */
throw error.stack;
}
}

View File

@ -431,6 +431,7 @@ function genericPrint(path, options, print) {
}
default:
/* istanbul ignore next */
throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
}
}

View File

@ -88,6 +88,7 @@ function genericPrint(path, options, print) {
}
default:
/* istanbul ignore next */
throw new Error("unknown htmlparser2 type: " + n.type);
}
}

View File

@ -17,6 +17,7 @@ const removeLines = docUtils.removeLines;
function genericPrint(path, options, print) {
const n = path.getValue();
/* istanbul ignore if */
if (!n) {
return "";
}
@ -380,6 +381,7 @@ function genericPrint(path, options, print) {
}
default:
/* istanbul ignore next */
throw new Error("unknown postcss type: " + JSON.stringify(n.type));
}
}