flow2schema/tests/run.js

38 lines
908 B
JavaScript
Raw Normal View History

2017-11-16 15:17:15 +03:00
import * as assert from 'assert';
import * as fs from 'fs';
import * as path from 'path';
2017-10-29 15:42:46 +03:00
2017-11-16 15:17:15 +03:00
import collect from '../src';
2017-10-29 15:42:46 +03:00
2017-11-05 12:28:10 +03:00
function run(title) {
2017-11-05 15:39:40 +03:00
let actual, expected;
// Run the collector only if the suite will be checked.
before(() => {
actual = collect(title + '.js');
expected = JSON.parse(fs.readFileSync(title + '.json', 'utf8'));
});
2017-11-02 21:52:35 +03:00
2017-11-05 12:28:10 +03:00
it('should provide expected schemas', () => {
assert.deepEqual(actual.schemas, expected.schemas);
});
2017-11-03 18:04:53 +03:00
2017-11-05 12:28:10 +03:00
it('should run expected tasks', () => {
assert.equal(actual.taskCount, expected.taskCount);
});
2017-11-05 00:44:25 +03:00
}
function main() {
2017-11-16 15:17:15 +03:00
process.chdir(path.join(__dirname, 'samples'));
2017-11-05 00:44:25 +03:00
2017-11-05 12:28:10 +03:00
fs.readdirSync('.')
2017-11-05 02:40:46 +03:00
.filter(name => path.extname(name) === '.js')
2017-11-05 12:28:10 +03:00
.forEach(name => {
const title = path.basename(name, '.js');
2017-11-05 00:44:25 +03:00
2017-11-05 12:28:10 +03:00
describe(title, () => run(title));
});
2017-10-29 15:42:46 +03:00
}
2017-11-05 00:44:25 +03:00
main();