Move tests into src/js/__tests__

This commit is contained in:
Peter Cottle 2015-03-22 14:42:01 -07:00
parent dfecf68690
commit 4331e4a981
11 changed files with 13 additions and 13 deletions

View file

@ -0,0 +1,49 @@
var TreeCompare = require('../graph/treeCompare');
var HeadlessGit = require('../git/headless').HeadlessGit;
var fs = require('fs');
prompt = require('prompt');
function getFile(truthy) {
var filename = (truthy) ?
'./git.spec.js' :
'./remote.spec.js';
return fs.readFileSync(filename, 'utf8');
}
function writeFile(truthy, content) {
var filename = (truthy) ?
'./git.spec.js' :
'./remote.spec.js';
fs.writeFileSync(filename, content);
}
prompt.start();
prompt.get(
['command', 'whatItDoes', 'intoGitSpec'],
function(err, result) {
var headless = new HeadlessGit();
headless.sendCommand(result.command);
setTimeout(function() {
var testCase = '\t\texpectTreeAsync(\n' +
"\t\t\t'" + result.command + "',\n" +
"\t\t\t'" + headless.gitEngine.printTree() + "'\n" +
"\t\t);\n";
console.log(testCase);
// now add it
var testFile = getFile(result.intoGitSpec);
// insert after the last })
var toSlice = testFile.lastIndexOf('})');
var partOne = testFile.slice(0, toSlice);
var partTwo = testFile.slice(toSlice);
var funcCall = "\tit('" + result.whatItDoes + "', function() {\n" +
testCase + "\t});\n\n";
writeFile(result.intoGitSpec, partOne + funcCall + partTwo);
}, 100);
}
);