2021-11-27 16:42:37 +01:00
|
|
|
import chai from 'chai'
|
2022-09-07 10:57:47 +02:00
|
|
|
import { Design } from '@freesewing/core'
|
2022-09-15 13:49:55 +02:00
|
|
|
import { plugin } from '../src/index.mjs'
|
2021-11-27 16:42:37 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
const measurements = {
|
|
|
|
chest: 100,
|
|
|
|
highBust: 90,
|
|
|
|
}
|
|
|
|
|
2022-09-07 10:57:47 +02:00
|
|
|
const Pattern = new Design()
|
2022-09-11 21:14:59 +02:00
|
|
|
const pattern = new Pattern({ measurements }).use(plugin)
|
|
|
|
pattern.draft()
|
2021-11-27 16:42:37 +01:00
|
|
|
|
|
|
|
describe('Bust plugin Tests', () => {
|
|
|
|
it('Should set swap the chest measurements', () => {
|
|
|
|
expect(pattern.settings.measurements.bust).to.equal(100)
|
|
|
|
expect(pattern.settings.measurements.chest).to.equal(90)
|
|
|
|
})
|
2022-01-27 20:52:55 +01:00
|
|
|
|
|
|
|
it('Should copy measurement from chest to bust and from highBust to chest', function () {
|
2022-08-28 12:05:47 +02:00
|
|
|
const testPattern = new Design({
|
|
|
|
measurements: {},
|
2022-09-11 21:14:59 +02:00
|
|
|
plugins: [plugin],
|
2022-08-28 12:05:47 +02:00
|
|
|
})
|
|
|
|
const pattern = new testPattern()
|
2022-09-11 21:14:59 +02:00
|
|
|
const userMeasurements = { chest: 50, highBust: 60 }
|
|
|
|
pattern.settings.measurements = userMeasurements
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
|
|
|
expect(pattern.settings.measurements.bust).to.equal(50)
|
|
|
|
expect(pattern.settings.measurements.chest).to.equal(60)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not overwrite existing bust measurements', function () {
|
2022-09-11 21:14:59 +02:00
|
|
|
let config = { measurements: {} }
|
|
|
|
const testPattern = new Design(config, plugin)
|
2022-01-27 20:52:55 +01:00
|
|
|
let pattern = new testPattern()
|
2022-09-11 21:14:59 +02:00
|
|
|
let userMeasurements = { chest: 50, highBust: 60, bust: 55 }
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.settings.measurements = userMeasurements
|
|
|
|
pattern.draft()
|
|
|
|
expect(pattern.settings.measurements.bust).to.equal(55)
|
|
|
|
expect(pattern.settings.measurements.chest).to.equal(50)
|
|
|
|
})
|
2021-11-27 16:42:37 +01:00
|
|
|
})
|