1
0
Fork 0
freesewing/plugins/plugin-gore/tests/plugin.test.mjs
joostdecock 26e282f5b7 fix: Fix tests after major chai upgrade
Note that the tests for Lumina are failing, but that's not related to
the chai upgrade, rather it seems these tests fail because of issues in
the design that we'll tackle later (it's a brand new design yet to be
released).
2024-02-04 12:14:42 +01:00

147 lines
4.1 KiB
JavaScript

import { expect } from 'chai'
import { round, Design } from '@freesewing/core'
import { plugin } from '../src/index.mjs'
describe('Gore Plugin Tests', () => {
it('Should create a default gore', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.anchorPoint = new Point(50, 50)
macro('gore', {
from: points.anchorPoint,
radius: 25,
gores: 4,
extraLength: 0,
prefix: 'gore',
})
return part
},
plugins: [plugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
let c = pattern.parts[0].test.points
expect(round(c.gorep1.y)).to.equal(50)
expect(round(c.gorep2.x)).to.equal(50)
expect(round(c.gorep2.y)).to.equal(30.37)
expect(round(c.gorep3.x)).to.equal(50)
expect(round(c.gorep3.y)).to.equal(30.37)
})
it('Should use a configurable number of gores', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.anchorPoint = new Point(50, 50)
macro('gore', {
from: points.anchorPoint,
radius: 25,
gores: 8,
extraLength: 0,
prefix: 'gore',
})
return part
},
plugins: [plugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
let c = pattern.parts[0].test.points
expect(round(c.gorep1.x)).to.equal(89.27)
expect(round(c.gorep1.y)).to.equal(50)
expect(round(c.gorep2.x)).to.equal(50)
expect(round(c.gorep2.y)).to.equal(40.18)
expect(round(c.gorep3.x)).to.equal(50)
expect(round(c.gorep3.y)).to.equal(40.18)
})
it('Should use a configurable extra length', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.anchorPoint = new Point(50, 50)
macro('gore', {
from: points.anchorPoint,
radius: 25,
gores: 4,
extraLength: 20,
prefix: 'gore',
})
return part
},
plugins: [plugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
let c = pattern.parts[0].test.points
expect(round(c.gorep1.x)).to.equal(109.27)
expect(round(c.gorep1.y)).to.equal(50)
expect(round(c.gorep2.x)).to.equal(70)
expect(round(c.gorep2.y)).to.equal(30.37)
expect(round(c.gorep3.x)).to.equal(50)
expect(round(c.gorep3.y)).to.equal(30.37)
})
it('Should use a configurable radius', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.anchorPoint = new Point(50, 50)
macro('gore', {
from: points.anchorPoint,
radius: 30,
gores: 4,
extraLength: 0,
prefix: 'gore',
})
return part
},
plugins: [plugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
let c = pattern.parts[0].test.points
expect(round(c.gorep1.x)).to.equal(97.12)
expect(round(c.gorep1.y)).to.equal(50)
expect(round(c.gorep2.x)).to.equal(50)
expect(round(c.gorep2.y)).to.equal(26.44)
expect(round(c.gorep3.x)).to.equal(50)
expect(round(c.gorep3.y)).to.equal(26.44)
})
it('Should generate a seam path', () => {
const part = {
name: 'test',
draft: ({ Point, points, macro, part }) => {
points.anchorPoint = new Point(50, 50)
macro('gore', {
from: points.anchorPoint,
radius: 25,
gores: 4,
extraLength: 0,
prefix: 'gore',
})
return part
},
plugins: [plugin],
}
const Test = new Design({ parts: [part] })
const pattern = new Test()
pattern.draft()
let c = pattern.parts[0].test.paths.goreseam.ops
expect(round(c[1].to.x)).to.equal(89.27)
expect(round(c[1].to.y)).to.equal(50)
expect(round(c[2].to.x)).to.equal(50)
expect(round(c[2].to.y)).to.equal(30.37)
})
})