2021-11-27 16:44:39 +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:44:39 +01:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
const measurements = {
|
|
|
|
seatBack: 60,
|
|
|
|
seat: 100,
|
|
|
|
waist: 100,
|
|
|
|
waistBack: 45,
|
|
|
|
crossSeam: 100,
|
2022-09-12 09:53:36 +02:00
|
|
|
crossSeamFront: 42,
|
2021-11-27 16:44:39 +01:00
|
|
|
}
|
2022-09-12 09:53:36 +02:00
|
|
|
const part = {
|
|
|
|
name: 'test',
|
2022-09-27 11:55:44 +02:00
|
|
|
draft: ({ points, Point, part }) => {
|
2022-09-12 09:53:36 +02:00
|
|
|
points.from = new Point(10, 20)
|
|
|
|
points.to = new Point(10, 230)
|
2022-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
return part
|
2022-09-12 09:53:36 +02:00
|
|
|
},
|
2022-09-27 11:55:44 +02:00
|
|
|
measurements: Object.keys(measurements),
|
|
|
|
plugins: [plugin],
|
2022-09-12 09:53:36 +02:00
|
|
|
}
|
2022-09-27 11:55:44 +02:00
|
|
|
const Pattern = new Design({ parts: [part] })
|
2021-11-27 16:44:39 +01:00
|
|
|
|
|
|
|
describe('Measurements Plugin Tests', () => {
|
|
|
|
it('Should set the extra measurements', () => {
|
2022-09-27 11:55:44 +02:00
|
|
|
const pattern = new Pattern({ measurements })
|
|
|
|
pattern.draft()
|
|
|
|
expect(pattern.settings[0].measurements.seatFront).to.equal(40)
|
|
|
|
expect(pattern.settings[0].measurements.seatFrontArc).to.equal(20)
|
|
|
|
expect(pattern.settings[0].measurements.seatBackArc).to.equal(30)
|
|
|
|
expect(pattern.settings[0].measurements.waistFront).to.equal(55)
|
|
|
|
expect(pattern.settings[0].measurements.waistFrontArc).to.equal(27.5)
|
|
|
|
expect(pattern.settings[0].measurements.crossSeamBack).to.equal(58)
|
2021-11-27 16:44:39 +01:00
|
|
|
})
|
2022-01-27 20:52:55 +01:00
|
|
|
|
|
|
|
it('Should calculate seatFront from seat and seatBack', function () {
|
2022-09-27 11:55:44 +02:00
|
|
|
const pattern = new Pattern({ measurements: { seat: 50, seatBack: 20 } })
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
2022-09-27 11:55:44 +02:00
|
|
|
expect(pattern.settings[0].measurements.seatFront).to.equal(30)
|
2022-01-27 20:52:55 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should calculate waistFrontArc and waistBackArc from waist and waistBack', function () {
|
2022-09-27 11:55:44 +02:00
|
|
|
const pattern = new Pattern({ measurements: { waist: 50, waistBack: 20 } })
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
2022-09-27 11:55:44 +02:00
|
|
|
expect(pattern.settings[0].measurements.waistFrontArc).to.equal(15)
|
|
|
|
expect(pattern.settings[0].measurements.waistBackArc).to.equal(10)
|
2022-01-27 20:52:55 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should calculate crossSeamBack from crossSeam and crossSeamFront', function () {
|
2022-09-27 11:55:44 +02:00
|
|
|
const pattern = new Pattern({ measurements: { crossSeam: 50, crossSeamFront: 20 } })
|
2022-01-27 20:52:55 +01:00
|
|
|
pattern.draft()
|
2022-09-27 11:55:44 +02:00
|
|
|
expect(pattern.settings[0].measurements.crossSeamBack).to.equal(30)
|
2022-01-27 20:52:55 +01:00
|
|
|
})
|
2021-11-27 16:44:39 +01:00
|
|
|
})
|