2024-02-04 12:14:42 +01:00
|
|
|
import { expect } 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 measurements = {
|
|
|
|
chest: 100,
|
|
|
|
highBust: 90,
|
|
|
|
}
|
2024-02-17 15:57:40 +01:00
|
|
|
const options = { draftForHighBust: true }
|
2021-11-27 16:42:37 +01:00
|
|
|
|
2022-09-07 10:57:47 +02:00
|
|
|
const Pattern = new Design()
|
2024-02-17 15:57:40 +01:00
|
|
|
const pattern = new Pattern({ measurements, options }).use(plugin)
|
2022-09-11 21:14:59 +02:00
|
|
|
pattern.draft()
|
2021-11-27 16:42:37 +01:00
|
|
|
|
|
|
|
describe('Bust plugin Tests', () => {
|
|
|
|
it('Should set swap the chest measurements', () => {
|
2022-09-25 15:03:09 +02:00
|
|
|
expect(pattern.settings[0].measurements.bust).to.equal(100)
|
|
|
|
expect(pattern.settings[0].measurements.chest).to.equal(90)
|
2021-11-27 16:42:37 +01:00
|
|
|
})
|
2022-01-27 20:52:55 +01:00
|
|
|
|
|
|
|
it('Should copy measurement from chest to bust and from highBust to chest', function () {
|
2024-02-17 15:57:40 +01:00
|
|
|
const testPattern = new Design({ measurements: [], options })
|
2022-09-25 15:03:09 +02:00
|
|
|
const pattern = new testPattern().use(plugin)
|
2022-09-11 21:14:59 +02:00
|
|
|
const userMeasurements = { chest: 50, highBust: 60 }
|
2022-09-25 15:03:09 +02:00
|
|
|
pattern.settings[0].measurements = userMeasurements
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
2022-09-25 15:03:09 +02:00
|
|
|
expect(pattern.settings[0].measurements.bust).to.equal(50)
|
|
|
|
expect(pattern.settings[0].measurements.chest).to.equal(60)
|
2022-01-27 20:52:55 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not overwrite existing bust measurements', function () {
|
2024-02-17 15:57:40 +01:00
|
|
|
let config = { measurements: [], options }
|
2022-09-11 21:14:59 +02:00
|
|
|
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-09-25 15:03:09 +02:00
|
|
|
pattern.settings[0].measurements = userMeasurements
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
2022-09-25 15:03:09 +02:00
|
|
|
expect(pattern.settings[0].measurements.bust).to.equal(55)
|
|
|
|
expect(pattern.settings[0].measurements.chest).to.equal(50)
|
2022-01-27 20:52:55 +01:00
|
|
|
})
|
2021-11-27 16:42:37 +01:00
|
|
|
})
|