fix(core): Issue with hiding dependencies
This commit is contained in:
parent
32890819bf
commit
48b366c57e
10 changed files with 165 additions and 167 deletions
|
@ -21,6 +21,7 @@ export function Part() {
|
|||
|
||||
// Enumerable properties
|
||||
this.render = true // FIXME: Replace render with hide
|
||||
this.hide = false // FIXME: Replace render with hide
|
||||
this.attributes = new Attributes()
|
||||
this.points = {}
|
||||
this.paths = {}
|
||||
|
@ -323,7 +324,9 @@ Part.prototype.shorthand = function () {
|
|||
const optionsProxy = {
|
||||
get: function (options, name) {
|
||||
if (typeof options[name] === 'undefined')
|
||||
self.context.store.log.warning(`Tried to access \`options.${name}\` but it is \`undefined\``)
|
||||
self.context.store.log.warning(
|
||||
`Tried to access \`options.${name}\` but it is \`undefined\``
|
||||
)
|
||||
return Reflect.get(...arguments)
|
||||
},
|
||||
set: (options, name, value) => (self.context.settings.options[name] = value),
|
||||
|
|
|
@ -13,9 +13,7 @@ import {
|
|||
} from './utils.mjs'
|
||||
|
||||
export function Path(debug = false) {
|
||||
|
||||
// Non-enumerable properties
|
||||
addNonEnumProp(this, 'render', true) // FIXME: replace with hide
|
||||
//addNonEnumProp(this, 'topLeft', false)
|
||||
//addNonEnumProp(this, 'bottomRight', false)
|
||||
//addNonEnumProp(this, 'attributes', new Attributes())
|
||||
|
@ -28,6 +26,7 @@ export function Path(debug = false) {
|
|||
this.attributes = new Attributes()
|
||||
this.topLeft = false
|
||||
this.bottomRight = false
|
||||
this.render = true
|
||||
}
|
||||
|
||||
/** Adds the log method for a path not created through the proxy **/
|
||||
|
@ -632,9 +631,7 @@ Path.prototype.divide = function () {
|
|||
if (!op.to.sitsRoughlyOn(current))
|
||||
paths.push(new Path(this.debug).withLog(this.log).move(current).line(op.to))
|
||||
} else if (op.type === 'curve') {
|
||||
paths.push(
|
||||
new Path(this.debug).withLog(this.log).move(current).curve(op.cp1, op.cp2, op.to)
|
||||
)
|
||||
paths.push(new Path(this.debug).withLog(this.log).move(current).curve(op.cp1, op.cp2, op.to))
|
||||
} else if (op.type === 'close') {
|
||||
paths.push(new Path(this.debug).withLog(this.log).move(current).line(start))
|
||||
}
|
||||
|
@ -646,15 +643,13 @@ Path.prototype.divide = function () {
|
|||
|
||||
/** Finds intersections between this path and an X value */
|
||||
Path.prototype.intersectsX = function (x) {
|
||||
if (typeof x !== 'number')
|
||||
this.log.error('Called `Path.intersectsX(x)` but `x` is not a number')
|
||||
if (typeof x !== 'number') this.log.error('Called `Path.intersectsX(x)` but `x` is not a number')
|
||||
return this.intersectsAxis(x, 'x')
|
||||
}
|
||||
|
||||
/** Finds intersections between this path and an Y value */
|
||||
Path.prototype.intersectsY = function (y) {
|
||||
if (typeof y !== 'number')
|
||||
this.log.error('Called `Path.intersectsX(y)` but `y` is not a number')
|
||||
if (typeof y !== 'number') this.log.error('Called `Path.intersectsX(y)` but `y` is not a number')
|
||||
return this.intersectsAxis(y, 'y')
|
||||
}
|
||||
|
||||
|
@ -781,9 +776,7 @@ Path.prototype.split = function (point) {
|
|||
firstHalf.push(new Path(this.debug).withLog(this.log).move(path.ops[0].to).line(point))
|
||||
pi++
|
||||
secondHalf = divided.slice(pi)
|
||||
secondHalf.unshift(
|
||||
new Path(this.debug).withLog(this.log).move(point).line(path.ops[1].to)
|
||||
)
|
||||
secondHalf.unshift(new Path(this.debug).withLog(this.log).move(point).line(path.ops[1].to))
|
||||
}
|
||||
} else if (path.ops[1].type === 'curve') {
|
||||
if (path.ops[0].to.sitsRoughlyOn(point)) {
|
||||
|
|
|
@ -239,7 +239,9 @@ Pattern.prototype.draft = function () {
|
|||
try {
|
||||
const result = this.__parts[partName].draft(this.parts[partName].shorthand())
|
||||
if (typeof result === 'undefined') {
|
||||
this.store.log.error(`Result of drafting part ${partName} was undefined. Did you forget to return the part?`)
|
||||
this.store.log.error(
|
||||
`Result of drafting part ${partName} was undefined. Did you forget to return the part?`
|
||||
)
|
||||
} else this.parts[partName] = result
|
||||
} catch (err) {
|
||||
this.store.log.error([`Unable to draft part \`${partName}\``, err])
|
||||
|
@ -657,26 +659,27 @@ Pattern.prototype.__resolveParts = function (count = 0) {
|
|||
}
|
||||
}
|
||||
for (const [name, part] of Object.entries(this.__parts)) {
|
||||
// Hide when hideAll is set
|
||||
if (part.hideAll) part.hide = true
|
||||
// Inject (from)
|
||||
if (part.from) {
|
||||
if (part.hideDependencies || part.hideAll) {
|
||||
part.from.hide = true
|
||||
part.from.hideAll = true
|
||||
}
|
||||
this.__parts[part.from.name] = part.from
|
||||
this.__inject[name] = part.from.name
|
||||
if (typeof this.__parts[part.from.name] === 'undefined') {
|
||||
if (part.hideDependencies || part.hideAll) {
|
||||
this.__parts[part.from.name].hide = true
|
||||
this.__parts[part.from.name].hideAll = true
|
||||
}
|
||||
//this.config = addPartConfig(this.__parts[part.from.name], this.config, this.store)
|
||||
}
|
||||
}
|
||||
// Simple dependency (after)
|
||||
if (part.after) {
|
||||
if (Array.isArray(part.after)) {
|
||||
for (const dep of part.after) {
|
||||
if (part.hideDependencies) dep.hide = true
|
||||
this.__parts[dep.name] = dep
|
||||
this.__addDependency(name, part, dep)
|
||||
}
|
||||
} else {
|
||||
if (part.hideDependencies) part.after.hide = true
|
||||
this.__parts[part.after.name] = part.after
|
||||
this.__addDependency(name, part, part.after)
|
||||
}
|
||||
|
@ -729,18 +732,16 @@ Pattern.prototype.__resolveDependencies = function (graph = false) {
|
|||
* configured dependencies.
|
||||
*/
|
||||
Pattern.prototype.needs = function (partName) {
|
||||
|
||||
// If only is unset, all parts are needed
|
||||
if (
|
||||
typeof this.settings.only === 'undefined' ||
|
||||
this.settings.only === false ||
|
||||
(Array.isArray(this.settings.only) && this.settings.only.length === 0)
|
||||
) return true
|
||||
)
|
||||
return true
|
||||
|
||||
// Make only to always be an array
|
||||
const only = typeof this.settings.only === 'string'
|
||||
? [ this.settings.only ]
|
||||
: this.settings.only
|
||||
const only = typeof this.settings.only === 'string' ? [this.settings.only] : this.settings.only
|
||||
|
||||
// Walk the only parts, checking each one for a match in its dependencies
|
||||
for (const part of only) {
|
||||
|
@ -777,7 +778,6 @@ Pattern.prototype.isHidden = function (partName) {
|
|||
if (Array.isArray(this.settings.only)) {
|
||||
if (this.settings.only.includes(partName)) return false
|
||||
}
|
||||
|
||||
if (this.__parts?.[partName]?.hide) return true
|
||||
if (this.__parts?.[partName]?.hideAll) return true
|
||||
|
||||
|
|
|
@ -548,7 +548,6 @@ export const addPartConfig = (part, config, store) => {
|
|||
config = addPartOptions(part, config, store)
|
||||
config = addPartMeasurements(part, config, store)
|
||||
config = addPartOptionalMeasurements(part, config, store)
|
||||
//config = addPartDependencies(part, config, store)
|
||||
config = addPartPlugins(part, config, store)
|
||||
|
||||
return config
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Design, Pattern, Path } from '../src/index.mjs'
|
|||
const expect = chai.expect
|
||||
|
||||
describe('Part', () => {
|
||||
|
||||
it('Shorthand should contain the part itself', () => {
|
||||
let dp
|
||||
const part = {
|
||||
|
@ -12,7 +11,7 @@ describe('Part', () => {
|
|||
draft: ({ part }) => {
|
||||
dp = part
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('Path', () => {
|
|||
paths.line = new Path().move(new Point(0, 0)).line(new Point(0, 40))
|
||||
paths.offset = paths.line.offset(10)
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -29,7 +29,7 @@ describe('Path', () => {
|
|||
.curve(new Point(0, 40), new Point(123, 34), new Point(23, 4))
|
||||
paths.offset = paths.curve.offset(10)
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -42,12 +42,10 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, part }) => {
|
||||
paths.curve = new Path()
|
||||
.move(new Point(0, 0))
|
||||
._curve(new Point(123, 34), new Point(23, 4))
|
||||
paths.curve = new Path().move(new Point(0, 0))._curve(new Point(123, 34), new Point(23, 4))
|
||||
paths.offset = paths.curve.offset(10)
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -60,12 +58,10 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, part }) => {
|
||||
paths.curve = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.curve_(new Point(40, 0), new Point(123, 34))
|
||||
paths.curve = new Path().move(new Point(0, 0)).curve_(new Point(40, 0), new Point(123, 34))
|
||||
paths.offset = paths.curve.offset(10)
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -98,11 +94,9 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, part }) => {
|
||||
paths.line = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(40, 0))
|
||||
paths.line = new Path().move(new Point(0, 0)).line(new Point(40, 0))
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -119,7 +113,7 @@ describe('Path', () => {
|
|||
.curve(new Point(0, 40), new Point(123, 34), new Point(23, 4))
|
||||
.close()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -136,7 +130,7 @@ describe('Path', () => {
|
|||
.curve(new Point(0, 40), new Point(123, 34), new Point(23, 4))
|
||||
.close()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -154,7 +148,7 @@ describe('Path', () => {
|
|||
.curve(new Point(0, 40), new Point(123, 34), new Point(23, 4))
|
||||
.close()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -825,7 +819,7 @@ describe('Path', () => {
|
|||
.attr('class', 'bar')
|
||||
.attr('class', 'overwritten', true)
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -1080,14 +1074,11 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, points }) => {
|
||||
paths.line = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, 40))
|
||||
.attr('class', 'foo')
|
||||
paths.line = new Path().move(new Point(0, 0)).line(new Point(0, 40)).attr('class', 'foo')
|
||||
paths.a = new Path().move(points.a).line(points.b)
|
||||
paths.b = paths.a.offset()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -1102,13 +1093,10 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, points }) => {
|
||||
paths.line = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, 40))
|
||||
.attr('class', 'foo')
|
||||
paths.line = new Path().move(new Point(0, 0)).line(new Point(0, 40)).attr('class', 'foo')
|
||||
paths.a = new Path().move(points.a).line(points.b).join()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
|
@ -1155,34 +1143,31 @@ describe('Path', () => {
|
|||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, points }) => {
|
||||
points.a = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, 40))
|
||||
.shiftFractionAlong()
|
||||
points.a = new Path().move(new Point(0, 0)).line(new Point(0, 40)).shiftFractionAlong()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.store.logs.error[0]).to.equal('Called `Path.shiftFractionAlong(fraction)` but `fraction` is not a number')
|
||||
expect(pattern.store.logs.error[0]).to.equal(
|
||||
'Called `Path.shiftFractionAlong(fraction)` but `fraction` is not a number'
|
||||
)
|
||||
})
|
||||
|
||||
it('Should log a warning when splitting a path on a non-point', () => {
|
||||
const part = {
|
||||
name: 'test',
|
||||
draft: ({ paths, Path, Point, points }) => {
|
||||
points.a = new Path()
|
||||
.move(new Point(0, 0))
|
||||
.line(new Point(0, 40))
|
||||
.split()
|
||||
points.a = new Path().move(new Point(0, 0)).line(new Point(0, 40)).split()
|
||||
return part
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.store.logs.error[0]).to.equal('Called `Path.split(point)` but `point` is not a `Point` object')
|
||||
expect(pattern.store.logs.error[0]).to.equal(
|
||||
'Called `Path.split(point)` but `point` is not a `Point` object'
|
||||
)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -5,31 +5,32 @@ const expect = chai.expect
|
|||
|
||||
describe('Pattern', () => {
|
||||
describe('Pattern.draft()', () => {
|
||||
|
||||
const partA = {
|
||||
name: 'test.partA',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['chest', 'waist'],
|
||||
options: {
|
||||
optA: { pct: 40, min: 20, max: 80 }
|
||||
optA: { pct: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
const partB = {
|
||||
name: 'test.partB',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['knee'],
|
||||
after: partA,
|
||||
plugins: [{
|
||||
plugins: [
|
||||
{
|
||||
name: 'testPlugin',
|
||||
hooks: {
|
||||
preRender: () => {}
|
||||
}
|
||||
}],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 }
|
||||
preRender: () => {},
|
||||
},
|
||||
draft: () => { }
|
||||
},
|
||||
],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => {},
|
||||
}
|
||||
const partC = {
|
||||
name: 'test.partC',
|
||||
|
@ -37,9 +38,9 @@ describe('Pattern', () => {
|
|||
optionalMeasurements: ['knee'],
|
||||
from: partB,
|
||||
options: {
|
||||
optC: { pct: 20, min: 10, max: 30 }
|
||||
optC: { pct: 20, min: 10, max: 30 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
|
||||
const Pattern = new Design({
|
||||
|
@ -47,7 +48,7 @@ describe('Pattern', () => {
|
|||
name: 'test',
|
||||
version: '1.2.3',
|
||||
},
|
||||
parts: [ partC ]
|
||||
parts: [partC],
|
||||
})
|
||||
const pattern = new Pattern()
|
||||
|
||||
|
@ -86,40 +87,42 @@ describe('Pattern', () => {
|
|||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['chest', 'waist'],
|
||||
options: {
|
||||
optA: { pct: 40, min: 20, max: 80 }
|
||||
optA: { pct: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
const partB = {
|
||||
name: 'test.partB',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['knee'],
|
||||
after: partA,
|
||||
plugins: [{
|
||||
plugins: [
|
||||
{
|
||||
name: 'testPlugin',
|
||||
hooks: {
|
||||
preRender: () => {}
|
||||
}
|
||||
}],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 }
|
||||
preRender: () => {},
|
||||
},
|
||||
draft: () => { }
|
||||
},
|
||||
],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => {},
|
||||
}
|
||||
const partC = {
|
||||
name: 'test.partC',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['knee'],
|
||||
options: {
|
||||
optC: { pct: 20, min: 10, max: 30 }
|
||||
optC: { pct: 20, min: 10, max: 30 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
const Pattern = new Design({
|
||||
parts: [ partA, partB, partC ]
|
||||
parts: [partA, partB, partC],
|
||||
})
|
||||
const pattern = new Pattern({
|
||||
only: [ 'test.partB' ]
|
||||
only: ['test.partB'],
|
||||
})
|
||||
pattern.init()
|
||||
expect(pattern.needs('test.partA')).to.equal(true)
|
||||
|
@ -133,40 +136,42 @@ describe('Pattern', () => {
|
|||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['chest', 'waist'],
|
||||
options: {
|
||||
optA: { pct: 40, min: 20, max: 80 }
|
||||
optA: { pct: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
const partB = {
|
||||
name: 'test.partB',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['knee'],
|
||||
after: partA,
|
||||
plugins: [{
|
||||
plugins: [
|
||||
{
|
||||
name: 'testPlugin',
|
||||
hooks: {
|
||||
preRender: () => {}
|
||||
}
|
||||
}],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 }
|
||||
preRender: () => {},
|
||||
},
|
||||
draft: () => { }
|
||||
},
|
||||
],
|
||||
options: {
|
||||
optB: { deg: 40, min: 20, max: 80 },
|
||||
},
|
||||
draft: () => {},
|
||||
}
|
||||
const partC = {
|
||||
name: 'test.partC',
|
||||
measurements: ['head', 'knee'],
|
||||
optionalMeasurements: ['knee'],
|
||||
options: {
|
||||
optC: { pct: 20, min: 10, max: 30 }
|
||||
optC: { pct: 20, min: 10, max: 30 },
|
||||
},
|
||||
draft: () => { }
|
||||
draft: () => {},
|
||||
}
|
||||
const Pattern = new Design({
|
||||
parts: [ partA, partB, partC ]
|
||||
parts: [partA, partB, partC],
|
||||
})
|
||||
const pattern = new Pattern({
|
||||
only: [ 'test.partB' ]
|
||||
only: ['test.partB'],
|
||||
})
|
||||
pattern.init()
|
||||
expect(pattern.wants('test.partA')).to.equal(false)
|
||||
|
@ -337,5 +342,4 @@ describe('Pattern', () => {
|
|||
|
||||
|
||||
*/
|
||||
|
||||
})
|
||||
|
|
|
@ -610,29 +610,29 @@ describe('Pattern', () => {
|
|||
expect(count).to.equal(1)
|
||||
})
|
||||
|
||||
it("Pattern.init() should register multiple methods on a single hook", () => {
|
||||
it('Pattern.init() should register multiple methods on a single hook', () => {
|
||||
const plugin = {
|
||||
name: "test",
|
||||
version: "0.1-test",
|
||||
name: 'test',
|
||||
version: '0.1-test',
|
||||
hooks: {
|
||||
preDraft: [
|
||||
function (pattern) {
|
||||
count++;
|
||||
count++
|
||||
},
|
||||
function (pattern) {
|
||||
count++;
|
||||
count++
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
const Pattern = new Design()
|
||||
const pattern = new Pattern()
|
||||
let count = 0
|
||||
pattern._draft = () => {}
|
||||
pattern.use(plugin)
|
||||
pattern.draft()
|
||||
expect(count).to.equal(2);
|
||||
});
|
||||
expect(count).to.equal(2)
|
||||
})
|
||||
|
||||
it('Should check whether created parts get the pattern context', () => {
|
||||
const Pattern = new Design()
|
||||
|
@ -660,7 +660,6 @@ describe('Pattern', () => {
|
|||
expect(Array.isArray(part.context.store.logs.warning)).to.equal(true)
|
||||
expect(Array.isArray(part.context.store.logs.error)).to.equal(true)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('Pattern.settings', () => {
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Snapped options', () => {
|
|||
name: 'test',
|
||||
options: {
|
||||
test: { pct: 30, min: 0, max: 100, snap: 12, toAbs },
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const patternA = new design({ options: { test: 0.13 }, measurements }).draft()
|
||||
|
@ -32,7 +32,7 @@ describe('Snapped options', () => {
|
|||
toAbs,
|
||||
snap: [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const patternA = new design({ options: { test: 0.13 }, measurements }).draft()
|
||||
|
@ -57,7 +57,7 @@ describe('Snapped options', () => {
|
|||
imperial: [25.4, 50.8, 76.2, 101.6],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const patternA = new design({ options: { test: 0.13 }, measurements, units: 'metric' }).draft()
|
||||
|
@ -84,13 +84,29 @@ describe('Snapped options', () => {
|
|||
imperial: [25.4, 50.8, 76.2, 101.6],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const patternA = new design({ options: { test: 0.13 }, measurements, units: 'imperial' }).draft()
|
||||
const patternB = new design({ options: { test: 0.27 }, measurements, units: 'imperial' }).draft()
|
||||
const patternC = new design({ options: { test: 0.97 }, measurements, units: 'imperial' }).draft()
|
||||
const patternD = new design({ options: { test: 0.01 }, measurements, units: 'imperial' }).draft()
|
||||
const patternA = new design({
|
||||
options: { test: 0.13 },
|
||||
measurements,
|
||||
units: 'imperial',
|
||||
}).draft()
|
||||
const patternB = new design({
|
||||
options: { test: 0.27 },
|
||||
measurements,
|
||||
units: 'imperial',
|
||||
}).draft()
|
||||
const patternC = new design({
|
||||
options: { test: 0.97 },
|
||||
measurements,
|
||||
units: 'imperial',
|
||||
}).draft()
|
||||
const patternD = new design({
|
||||
options: { test: 0.01 },
|
||||
measurements,
|
||||
units: 'imperial',
|
||||
}).draft()
|
||||
expect(patternA.settings.absoluteOptions.test).to.equal(50.8)
|
||||
expect(patternB.settings.absoluteOptions.test).to.equal(101.6)
|
||||
expect(patternC.settings.absoluteOptions.test).to.equal(388)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue