Refactor, units, tests
This commit is contained in:
parent
519c34bc60
commit
cd90705ba1
24 changed files with 1221 additions and 1222 deletions
28
test/complex/index.js
Normal file
28
test/complex/index.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const yaml = require('js-yaml')
|
||||
const glob = require('glob')
|
||||
const u = require('../../src/utils')
|
||||
const ergogen = require('../../src/ergogen')
|
||||
|
||||
const cap = s => s.charAt(0).toUpperCase() + s.slice(1)
|
||||
|
||||
for (const part of ['points', 'outlines', 'cases', 'pcbs']) {
|
||||
describe(cap(part), function() {
|
||||
const dir = path.join(__dirname, part)
|
||||
for (const input_path of glob.sync(path.join(dir, '*.yaml'))) {
|
||||
const basename = path.basename(input_path, '.yaml')
|
||||
const title = basename.split('_').join(' ')
|
||||
it(title, function() {
|
||||
const dirname = path.dirname(input_path)
|
||||
const input = yaml.load(fs.readFileSync(input_path).toString())
|
||||
const actual = ergogen.process(input, true)
|
||||
for (const expected_path of glob.sync(path.join(dirname, basename + '___*'))) {
|
||||
const expected = JSON.parse(fs.readFileSync(expected_path).toString())
|
||||
const comp_path = expected_path.split('___')[1].split('.')[0].split('_').join('.')
|
||||
u.deep(actual, comp_path).should.deep.equal(expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue