1
0
Fork 0
freesewing/plugins/plugin-bust/tests/plugin.test.mjs

42 lines
1.5 KiB
JavaScript
Raw Normal View History

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'
const measurements = {
chest: 100,
highBust: 90,
}
const options = { draftForHighBust: true }
2022-09-07 10:57:47 +02:00
const Pattern = new Design()
const pattern = new Pattern({ measurements, options }).use(plugin)
2022-09-11 21:14:59 +02:00
pattern.draft()
describe('Bust plugin Tests', () => {
it('Should set swap the chest measurements', () => {
expect(pattern.settings[0].measurements.bust).to.equal(100)
expect(pattern.settings[0].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 () {
const testPattern = new Design({ measurements: [], options })
const pattern = new testPattern().use(plugin)
2022-09-11 21:14:59 +02:00
const userMeasurements = { chest: 50, highBust: 60 }
pattern.settings[0].measurements = userMeasurements
2022-01-27 20:52:55 +01:00
pattern.draft()
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 () {
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 }
pattern.settings[0].measurements = userMeasurements
2022-01-27 20:52:55 +01:00
pattern.draft()
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
})
})