1
0

Further testing

This commit is contained in:
Bán Dénes 2021-07-18 00:39:33 +02:00
parent 4105718ec6
commit b159cfa9f7
13 changed files with 440 additions and 4 deletions

View File

@ -37,9 +37,12 @@ const process = async (raw, debug=false, logger=()=>{}) => {
logger('Parsing points...')
if (!config.points) {
throw new Error('Input does not contain any points!')
throw new Error('Input does not contain a points clause!')
}
const points = points_lib.parse(config.points, units)
if (!Object.keys(points).length) {
throw new Error('Input does not contain any points!')
}
if (debug) {
results.points = points
results.demo = io.twodee(points_lib.visualize(points), debug)

View File

@ -40,6 +40,9 @@ const render_zone = exports._render_zone = (zone_name, zone, anchor, global_key,
// column layout
if (!Object.keys(cols).length) {
cols.default = {}
}
let first_col = true
for (let [col_name, col] of Object.entries(cols)) {
@ -218,8 +221,8 @@ const perform_mirror = exports._perform_mirror = (point, axis) => {
exports.parse = (config, units) => {
// config sanitization
a.unexpected(config, 'points', ['units', 'zones', 'key', 'rotate', 'mirror'])
const zones = a.sane(config.zones || {}, 'points.zones', 'object')()
a.unexpected(config, 'points', ['zones', 'key', 'rotate', 'mirror'])
const zones = a.sane(config.zones, 'points.zones', 'object')()
const global_key = a.sane(config.key || {}, 'points.key', 'object')()
const global_rotate = a.sane(config.rotate || 0, 'points.rotate', 'number')(units)
const global_mirror = config.mirror

View File

@ -0,0 +1,130 @@
{
"matrix_left_bottom": {
"x": 0,
"y": 0,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_bottom",
"colrow": "left_bottom",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "bottom"
}
},
"matrix_left_top": {
"x": 0,
"y": 19,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_top",
"colrow": "left_top",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "top"
}
},
"matrix_right_bottom": {
"x": 24.181350600000002,
"y": 5.750154,
"r": 5,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_bottom",
"colrow": "right_bottom",
"col": {
"stagger": 5,
"spread": 25,
"rotate": 5,
"origin": [
-9,
-9
],
"rows": {},
"key": {},
"name": "right"
},
"row": "bottom"
}
},
"matrix_right_top": {
"x": 22.525391499999998,
"y": 24.6778532,
"r": 5,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_top",
"colrow": "right_top",
"col": {
"stagger": 5,
"spread": 25,
"rotate": 5,
"origin": [
-9,
-9
],
"rows": {},
"key": {},
"name": "right"
},
"row": "top"
}
}
}

3
test/points/default.yaml Normal file
View File

@ -0,0 +1,3 @@
points:
zones:
matrix: {}

View File

@ -0,0 +1,34 @@
{
"matrix_default_default": {
"x": 0,
"y": 0,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_default_default",
"colrow": "default_default",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "default"
},
"row": "default"
}
}
}

View File

@ -0,0 +1,16 @@
points:
zones:
matrix:
columns:
left:
middle:
rows:
top:
right:
stagger: u
row_overrides:
home:
top:
rows:
bottom:
home:

View File

@ -0,0 +1,246 @@
{
"matrix_left_bottom": {
"x": 0,
"y": 0,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_bottom",
"colrow": "left_bottom",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "bottom"
}
},
"matrix_left_home": {
"x": 0,
"y": 19,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_left_home",
"colrow": "left_home",
"col": {
"stagger": 0,
"spread": 0,
"rotate": 0,
"origin": [
0,
0
],
"rows": {},
"key": {},
"name": "left"
},
"row": "home"
}
},
"matrix_middle_bottom": {
"x": 19,
"y": 0,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_bottom",
"colrow": "middle_bottom",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "bottom"
}
},
"matrix_middle_home": {
"x": 19,
"y": 19,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_home",
"colrow": "middle_home",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "home"
}
},
"matrix_middle_top": {
"x": 19,
"y": 38,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_middle_top",
"colrow": "middle_top",
"col": {
"rows": {
"top": {}
},
"stagger": 0,
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"key": {},
"name": "middle"
},
"row": "top"
}
},
"matrix_right_home": {
"x": 38,
"y": 19,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_home",
"colrow": "right_home",
"col": {
"stagger": 19,
"row_overrides": {
"home": {},
"top": {}
},
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {
"home": {},
"top": {}
},
"key": {},
"name": "right"
},
"row": "home"
}
},
"matrix_right_top": {
"x": 38,
"y": 38,
"r": 0,
"meta": {
"shift": [
0,
0
],
"rotate": 0,
"padding": 19,
"width": 1,
"height": 1,
"skip": false,
"asym": "both",
"name": "matrix_right_top",
"colrow": "right_top",
"col": {
"stagger": 19,
"row_overrides": {
"home": {},
"top": {}
},
"spread": 19,
"rotate": 0,
"origin": [
0,
0
],
"rows": {
"home": {},
"top": {}
},
"key": {},
"name": "right"
},
"row": "top"
}
}
}

View File

@ -51,7 +51,8 @@ describe('Interface', function() {
ergogen.process(kle, true, logger).should.be.rejectedWith('KLE'),
ergogen.process('not an object', true, logger).should.be.rejectedWith('object'),
ergogen.process({}, true, logger).should.be.rejectedWith('empty'),
ergogen.process({not_points: {}}, true, () => {}).should.be.rejectedWith('any points')
ergogen.process({not_points: {}}, true, () => {}).should.be.rejectedWith('points clause'),
ergogen.process({points: {zones: {}}}, true, () => {}).should.be.rejectedWith('any points')
])
})