Add basic interface tests
This commit is contained in:
parent
5cd8985343
commit
7f8b1c4c63
1 changed files with 76 additions and 0 deletions
76
test/unit/interface.js
Normal file
76
test/unit/interface.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
const u = require('../../src/utils')
|
||||||
|
const ergogen = require('../../src/ergogen')
|
||||||
|
|
||||||
|
const minimal = {
|
||||||
|
'points.zones.matrix': {
|
||||||
|
columns: {col: {}},
|
||||||
|
rows: {row: {}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const full = {
|
||||||
|
'points.zones.matrix': {
|
||||||
|
columns: {col: {}},
|
||||||
|
rows: {row: {}}
|
||||||
|
},
|
||||||
|
'outlines.exports': {
|
||||||
|
export: [{
|
||||||
|
type: 'keys',
|
||||||
|
side: 'left',
|
||||||
|
size: 18
|
||||||
|
}],
|
||||||
|
_export: [{
|
||||||
|
type: 'keys',
|
||||||
|
side: 'left',
|
||||||
|
size: 18
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
cases: {
|
||||||
|
export: [{
|
||||||
|
name: 'export',
|
||||||
|
extrude: 1
|
||||||
|
}],
|
||||||
|
_export: [{
|
||||||
|
name: 'export',
|
||||||
|
extrude: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
pcbs: {
|
||||||
|
export: {},
|
||||||
|
_export: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// to check whether the output has "private" exports
|
||||||
|
const underscore = obj => {
|
||||||
|
for (const val of Object.values(obj)) {
|
||||||
|
for (const key of Object.keys(val)) {
|
||||||
|
if (key.startsWith('_')) return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('Interface', function() {
|
||||||
|
|
||||||
|
it('minimal', function() {
|
||||||
|
underscore(ergogen.process(minimal)).should.be.false
|
||||||
|
})
|
||||||
|
|
||||||
|
it('production', function() {
|
||||||
|
underscore(ergogen.process(full, false)).should.be.false
|
||||||
|
})
|
||||||
|
|
||||||
|
it('debug', function() {
|
||||||
|
underscore(ergogen.process(full, true)).should.be.true
|
||||||
|
})
|
||||||
|
|
||||||
|
it('logging', function() {
|
||||||
|
const flag = {value: false}
|
||||||
|
const logger = msg => { flag.value = true }
|
||||||
|
ergogen.process(full, false, logger)
|
||||||
|
flag.value.should.be.true
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue