forked from koajs/kick-off-koa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
21 lines (18 loc) · 835 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var execSync = require('child_process').execSync;
var assert = require('assert');
var glob = require('glob');
var path = require('path');
var fs = require('fs');
var stripAnsi = require('strip-ansi');
var files = glob.sync('exercises/*/solution/solution.js');
files.forEach(function (file) {
var name = path.basename(path.dirname(path.dirname(file)));
execSync('./kick-off-koa.js select ' + name);
var submission = execSync('./kick-off-koa.js run ' + file).toString();
var result = fs.readFileSync(file.replace(/\.js$/, '.txt'), 'utf8');
assert(submission === result);
// check verify output include solution file
var v = execSync('./kick-off-koa.js verify ' + file).toString();
var solution = fs.readFileSync(file, 'utf8');
assert(stripAnsi(v).replace(/\s*/g, '').indexOf(solution.replace(/\s*/g, '')) >= 0);
});