1
0
Fork 0

chore: Test updates

There was an issue in the pattern tests that meant
config options where skipped as soon as a static
number of string was encountered

I've also added testing for non-human models (dolls, giants)
as it seems some patterns to not pass the antperson test
so this would be a way to catch that (and enforce it)
This commit is contained in:
joostdecock 2021-09-11 15:50:32 +02:00
parent 11d8640fc8
commit b3fdac8c8c
3 changed files with 73 additions and 4 deletions

View file

@ -110,7 +110,9 @@ const testPatternConfig = (design, pattern, expect, models, patterns) => {
* Test validity of the pattern's options
*/
it('Pattern options:', () => true)
console.log(pattern.config.options)
for (let name in pattern.config.options) {
console.log(name)
let option = pattern.config.options[name]
let type = typeof option
if (type === 'object' && typeof option.pct !== 'undefined') {
@ -184,10 +186,10 @@ const testPatternConfig = (design, pattern, expect, models, patterns) => {
})
} else if (type === 'number') {
// Static number
return true
it(` - '${name}' is a static number`, () => true)
} else if (type === 'string') {
// Static string
return true
it(` - '${name}' is a static string`, () => true)
}
}
}

View file

@ -41,7 +41,7 @@ const testPatternDrafting = (design, Pattern, expect, models, patterns) => {
* Draft pattern for different models
*/
if (isGarment(design)) {
it('Draft for different models:', () => true)
it('Draft for human models:', () => true)
for (let size in ourModels) {
it(` - Drafting for ${size} (${breasts ? 'with' : 'no'} breasts)`, () => {
@ -54,6 +54,39 @@ const testPatternDrafting = (design, Pattern, expect, models, patterns) => {
).to.equal(true)
})
}
// Do the same for fantistical models (dolls, giants)
it('Draft for non-human models:', () => 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) {
it(` - Drafting for ${size} (${breasts ? 'with' : 'no'} breasts)`, () => {
expect(
doesItDraft(
new Pattern({
measurements: models[size]
})
)
).to.equal(true)
})
}
}

View file

@ -73,7 +73,7 @@ const testPatternSampling = (design, Pattern, expect, models, patterns) => {
/*
* Sample pattern for different models
*/
it('Sample pattern for different models:' , () => {
it('Sample pattern for size range:' , () => {
expect(doesItSample(new Pattern({
sample: {
type: 'models',
@ -84,6 +84,40 @@ const testPatternSampling = (design, Pattern, expect, models, patterns) => {
})
}
if (['rendertest', 'tutorial', 'examples'].indexOf(design) === -1) {
/*
* Sample pattern with fractional sizes (antperson tests)
*/
const fractionModel = fraction => {
const model = {}
for (const [measie, value] of Object.entries(ourModels.size40)) {
model[measie] = value * fraction
}
return model
}
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)
})
}
}
module.exports = testPatternSampling