2022-09-09 20:20:38 +02:00
|
|
|
import chai from 'chai'
|
|
|
|
import { Design } from '../src/index.mjs'
|
2022-08-25 11:47:54 +02:00
|
|
|
|
|
|
|
const expect = chai.expect
|
2019-02-16 09:27:38 +01:00
|
|
|
|
2022-08-27 09:27:07 +02:00
|
|
|
describe('Design', () => {
|
2022-09-09 20:20:38 +02:00
|
|
|
it('Design constructor should return pattern constructor', () => {
|
|
|
|
const Pattern = new Design()
|
|
|
|
expect(typeof Pattern).to.equal('function')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Design constructor should load the default config', () => {
|
|
|
|
const Pattern = new Design()
|
2022-09-24 12:44:41 +02:00
|
|
|
const config = Pattern.designConfig
|
|
|
|
expect(Array.isArray(config.parts)).to.equal(true)
|
|
|
|
expect(config.parts.length).to.equal(0)
|
|
|
|
expect(typeof config.data).to.equal('object')
|
|
|
|
expect(Object.keys(config.data).length).to.equal(0)
|
2022-09-09 20:20:38 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it(`Design constructor should add options to config`, () => {
|
|
|
|
const settings = {
|
2022-08-27 09:27:07 +02:00
|
|
|
options: {
|
2022-09-09 20:20:38 +02:00
|
|
|
one: { pct: 50, min: 0, max: 100 },
|
|
|
|
two: { deg: 10, min: 5, max: 15 },
|
2022-08-27 09:27:07 +02:00
|
|
|
},
|
2022-09-09 20:20:38 +02:00
|
|
|
}
|
|
|
|
const Pattern = new Design(settings)
|
2022-09-24 12:44:41 +02:00
|
|
|
const o = Pattern.designConfig.options
|
2022-09-09 20:20:38 +02:00
|
|
|
expect(Object.keys(o).length).to.equal(2)
|
|
|
|
expect(o.one.pct).to.equal(50)
|
|
|
|
expect(o.one.min).to.equal(0)
|
|
|
|
expect(o.one.max).to.equal(100)
|
|
|
|
expect(o.two.deg).to.equal(10)
|
|
|
|
expect(o.two.min).to.equal(5)
|
|
|
|
expect(o.two.max).to.equal(15)
|
|
|
|
})
|
2022-08-07 17:29:33 +02:00
|
|
|
})
|