Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
testify: work in progress, support for generating babel whitelist con…
Browse files Browse the repository at this point in the history
…fig, per #9
  • Loading branch information
getify committed Jul 20, 2015
1 parent ad78ad1 commit a4c9328
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions lib/testify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,38 @@ function visitNode(node,state) {
// TODO: add more ES6 checks
}

function babelWhitelist(tests) {
var mappings = {
"es6.arrowFunctions": ["arrow"],
"es6.blockScoping": ["letConst","letLoop","constLoop"],
"es6.classes": ["classes"],
"es6.constants": ["letConst","constLoop"],
"es6.destructuring": ["destructuring","paramDestructuring"],
"es6.modules": ["moduleExport","moduleImport"],
"es6.objectSuper": ["objectSuper"],
"es6.parameters.default": ["defaultParameter"],
"es6.parameters.rest": ["spreadRest"],
"es6.properties.computed": ["computedProperty"],
"es6.properties.shorthand": ["conciseMethodProperty"],
"es6.regex.sticky": ["stickyRegExp"],
"es6.regex.unicode": ["unicodeRegExp"],
"es6.spec.blockScoping": ["letTDZ","letLoopScope"],
"es6.spec.symbols": ["symbolImplicitCoercion"],
"es6.spec.templateLiterals": ["templateString"],
"es6.spread": ["spreadRest"],
"es6.tailCall": ["TCO"],
"es6.templateLiterals": ["templateString"],
"regenerator": ["generator"]
};

return Object.keys(mappings)
.filter(function filterer(transformer){
return mappings[transformer].some(function somer(test){
return ~tests.indexOf(test);
});
});
}

function scan(opts) {
var output = "";

Expand Down Expand Up @@ -636,14 +668,17 @@ function scan(opts) {
output += "}";
}
else if (OPTS.output == "json") {
output = JSON.stringify(tests_needed);
output = tests_needed;
}
else if (OPTS.output == "babel") {
output = babelWhitelist(tests_needed);
}
}
else {
if (OPTS.output == "simple") {
output = "function checkFeatureTests(testResults){return true}";
output = "function checkFeatureTests(){return true}";
}
else if (OPTS.output == "json") {
else {
output = [];
}
}
Expand Down

0 comments on commit a4c9328

Please sign in to comment.