From 2491fcdf8dfbd27e61d3a5f37c286b66c8678d61 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sun, 25 Sep 2022 10:46:50 +0200 Subject: [PATCH] chore: Updated tests for core changes --- tests/designs/config.mjs | 31 ++++++++++++++++--------------- tests/designs/drafting.mjs | 10 ++++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tests/designs/config.mjs b/tests/designs/config.mjs index c0f6164f0a7..3cb8c910d49 100644 --- a/tests/designs/config.mjs +++ b/tests/designs/config.mjs @@ -23,30 +23,31 @@ const mmAllowed = ['rendertest'] * @param string Pattern: The Pattern constructor */ export const testPatternConfig = (Pattern) => { - const pattern = new Pattern() - const config = pattern.getConfig() + //const pattern = new Pattern() + const designConfig = Pattern.designConfig + const patternConfig = Pattern.patternConfig it('Pattern data:', () => true) it(` - 'name' should be set and be a non-empty string`, () => { - expect(typeof config.data.name).to.equal('string') - expect(config.data.name.length > 1).to.be.true + expect(typeof designConfig.data.name).to.equal('string') + expect(designConfig.data.name.length > 1).to.be.true }) // it(` - 'version' should be set and be a non-empty string`, () => { - expect(typeof config.data.version).to.equal('string') - expect(config.data.version.length > 1).to.be.true + expect(typeof designConfig.data.version).to.equal('string') + expect(designConfig.data.version.length > 1).to.be.true }) it(` - 'version' should be a proper semantic version`, () => { - const chunks = config.data.version.split('.') + const chunks = designConfig.data.version.split('.') if (chunks.length > 3) { - expect(config.data.version.split('.').length).to.equal(4) + expect(designConfig.data.version.split('.').length).to.equal(4) expect(chunks[2]).to.contain.oneOf(['-alpha', '-beta', '-rc']) } - else expect(config.version.split('.').length).to.equal(3) + else expect(designConfig.version.split('.').length).to.equal(3) }) it('Monorepo data:', () => true) // Store these for re-use - const name = getShortName(config.data.name) + const name = getShortName(designConfig.data.name) const family = getFamily(name) it(` - 'name' should be resolvable to a short name`, () => { expect(typeof name).to.equal('string') @@ -94,13 +95,13 @@ export const testPatternConfig = (Pattern) => { if (family !== 'utilities') { // Ensure required measurements are known measurements it('Required measurements:', () => true) - for (const measurement of config.measurements || []) { + for (const measurement of patternConfig.measurements || []) { it(` - '${measurement}' should be a known measurement`, () => { expect(measurements.indexOf(measurement)).to.not.equal(-1) }) } it('Optional measurements:', () => true) - for (let measurement of config.optionalMeasurements || []) { + for (let measurement of patternConfig.optionalMeasurements || []) { it(` - '${measurement}' should be a known measurement`, () => { expect(measurements.indexOf(measurement)).to.not.equal(-1) }) @@ -109,8 +110,8 @@ export const testPatternConfig = (Pattern) => { // Test validity of the pattern's options it('Pattern options:', () => true) - for (const name in config.options) { - const option = config.options[name] + for (const name in patternConfig.options) { + const option = patternConfig.options[name] const type = typeof option if (type === 'object' && typeof option.pct !== 'undefined') { it(` - If it has a 'menu' property, it should be a string or method`, () => { @@ -155,7 +156,7 @@ export const testPatternConfig = (Pattern) => { it(` - Should have a maximum >= the default value`, () => { expect(option.max >= option.mm).to.be.true }) - if (mmAllowed.indexOf(getShortName(config.data.name)) === -1) { + if (mmAllowed.indexOf(getShortName(designConfig.data.name)) === -1) { it(` - Patterns should not use mm options`, () => { expect("Does not use mm").to.be.true }) diff --git a/tests/designs/drafting.mjs b/tests/designs/drafting.mjs index d792bbe9af3..e8d161efad6 100644 --- a/tests/designs/drafting.mjs +++ b/tests/designs/drafting.mjs @@ -14,8 +14,8 @@ const expect = chai.expect */ export const testPatternDrafting = (Pattern, log = false) => { const pattern = new Pattern() - const config = pattern.getConfig() - const design = getShortName(config.data.name) + const config = Pattern.patternConfig + const design = getShortName(Pattern.designConfig.data.name) const family = getFamily(design) // Helper method to try/catch pattern drafting @@ -23,9 +23,11 @@ export const testPatternDrafting = (Pattern, log = false) => { try { pattern.draft().render() if (log) { - console.log(pattern.stores[0].logs) + console.log(pattern.store.logs) + console.log(pattern.setStores[0].logs) } - if (pattern.stores[0].logs.error.length < 1) return true + if (pattern.store.logs.error.length < 1) return true + if (pattern.setStores[0].logs.error.length < 1) return true return false } catch (err) { if (log) console.log(err)