1
0
Fork 0

chore: Added doll/giant to pattern tests

This commit is contained in:
joostdecock 2021-09-12 13:13:57 +02:00
parent 56e306d13a
commit 31d7632b75
3 changed files with 76 additions and 50 deletions

View file

@ -1,3 +1,5 @@
const nonHuman = require('./non-human-measurements.js')
// Some patterns are different
const isGarment = design => ([
'rendertest',
@ -41,7 +43,7 @@ const testPatternDrafting = (design, Pattern, expect, models, patterns, log=fals
* Draft pattern for different models
*/
if (isGarment(design)) {
it('Draft for human models:', () => true)
it('Draft for humans:', () => true)
for (let size in ourModels) {
it(` - Drafting for ${size} (${breasts ? 'with' : 'no'} breasts)`, () => {
@ -56,32 +58,28 @@ const testPatternDrafting = (design, Pattern, expect, models, patterns, log=fals
}
// Do the same for fantistical models (dolls, giants)
it('Draft for non-human models:', () => true)
it('Draft for dolls:', () => true)
const fractionModel = fraction => {
const model = {}
for (const [measie, value] of Object.entries(ourModels.size40)) {
model[measie] = value * fraction
}
return model
}
const models = {
// These are just names, don't read too much into it
'Gnome (0.1)': fractionModel(0.1),
'Halfling (0.2)': fractionModel(0.2),
'Goblin (0.5)': fractionModel(0.5),
'Dwarf (0.75)': fractionModel(0.75),
'Elf (1.5)': fractionModel(1.5),
'Ogre (2.5)': fractionModel(2.5),
'Firbolg (5)': fractionModel(5),
}
for (let size in models) {
for (let size in nonHuman[breasts ? 'withBreasts' : 'withoutBreasts'].dolls) {
it(` - Drafting for ${size} (${breasts ? 'with' : 'no'} breasts)`, () => {
expect(
doesItDraft(
new Pattern({
measurements: models[size]
measurements: nonHuman[breasts ? 'withBreasts' : 'withoutBreasts'].dolls[size]
}), log
)
).to.equal(true)
})
}
it('Draft for giants:', () => true)
for (let size in nonHuman[breasts ? 'withBreasts' : 'withoutBreasts'].giants) {
it(` - Drafting for ${size} (${breasts ? 'with' : 'no'} breasts)`, () => {
expect(
doesItDraft(
new Pattern({
measurements: nonHuman[breasts ? 'withBreasts' : 'withoutBreasts'].giants[size]
}), log
)
).to.equal(true)

View file

@ -0,0 +1,44 @@
const { withBreasts, withoutBreasts } = require('@freesewing/models')
const nonHuman = {
withoutBreasts: {
dolls: {},
giants: {}
},
withBreasts: {
dolls: {},
giants: {}
}
}
const round = val => Math.round(val*10)/10
for (let i=0.1;i<1;i+=0.1) {
const name = `Doll ${Math.round(i*10)}/10`
nonHuman.withBreasts.dolls[name] = {}
// withBreasts: Based on Anneke (size 34)
for (const [m, val] of Object.entries(withBreasts.size34)) {
nonHuman.withBreasts.dolls[name][m] = round(val * i)
}
// withoutBreasts: Based on Ronan (size 42)
nonHuman.withoutBreasts.dolls[name] = {}
for (const [m, val] of Object.entries(withoutBreasts.size42)) {
nonHuman.withoutBreasts.dolls[name][m] = round(val * i)
}
}
for (let i=1;i<=2.5;i+=0.5) {
const name = `Giant ${i}/1`
nonHuman.withBreasts.giants[name] = {}
// withBreasts: Based on Anneke (size 34)
for (const [m, val] of Object.entries(withBreasts.size34)) {
nonHuman.withBreasts.giants[name][m] = round(val * i)
}
nonHuman.withoutBreasts.giants[name] = {}
// withoutBreasts: Based on Ronan (size 42)
for (const [m, val] of Object.entries(withoutBreasts.size42)) {
nonHuman.withoutBreasts.giants[name][m] = round(val * i)
}
}
module.exports = nonHuman

View file

@ -1,3 +1,4 @@
const nonHuman = require('./non-human-measurements.js')
/*
* This runs unit tests for pattern sampling
* It expects the following:
@ -86,36 +87,19 @@ const testPatternSampling = (design, Pattern, expect, models, patterns) => {
if (['rendertest', 'tutorial', 'examples'].indexOf(design) === -1) {
/*
* Sample pattern with fractional sizes (antperson tests)
* Sample pattern for dolls & giants
*/
const fractionModel = fraction => {
const model = {}
for (const [measie, value] of Object.entries(ourModels.size40)) {
model[measie] = value * fraction
}
return model
for (const type of ['dolls', 'giants']) {
it(`Sample pattern for ${type}:` , () => {
expect(doesItSample(new Pattern({
sample: {
type: 'models',
models: nonHuman[breasts ? 'withBreasts' : 'withoutBreasts'][type]
},
measurements
}))).to.equal(true)
})
}
const models = {
oneTenth: fractionModel(0.1),
oneFifth: fractionModel(0.2),
oneHalf: fractionModel(0.5),
threeQuarters: fractionModel(0.5),
oneFifty: fractionModel(1.5),
twoFifty: fractionModel(2.5),
five: fractionModel(5),
ten: fractionModel(10),
}
it('Sample pattern for fantastic measurements:' , () => {
expect(doesItSample(new Pattern({
sample: {
type: 'models',
models,
},
measurements
}))).to.equal(true)
})
}
}