1
0
Fork 0

Added sampling of static options

This commit is contained in:
Joost De Cock 2018-09-07 16:25:17 +02:00
parent 829baa469b
commit 164c40c695
2 changed files with 3 additions and 2 deletions

View file

@ -147,7 +147,9 @@ Pattern.prototype.sampleOption = function(optionName) {
let parts = this.sampleParts();
let option = this.config.options[optionName];
if (typeof option.min === "undefined" || typeof option.max === "undefined") {
throw "Cannot sample an option without min and max values";
let min = option * 0.9;
let max = option * 1.1;
option = { min, max };
}
if (typeof option.pct !== "undefined") factor = 100;
val = option.min / factor;

View file

@ -98,7 +98,6 @@ it("Should sample an option", () => {
pattern.sample();
expect(pattern.parts.a.paths.test_1.render).to.equal(true);
expect(pattern.parts.b.paths.test_10.ops[1].to.y).to.equal(10);
expect(() => pattern.sampleOption("bonus")).to.throw();
});
it("Should sample a measurement", () => {