1
0
Fork 0
freesewing/packages/core/tests/bezierjs.test.mjs
Jonathan Haas 5672638bf9 [core] feat: Hotfix the reduce function in the bezier library (#224)
Fixes #117

Co-authored-by: joostdecock <joost@joost.at>
Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/224
Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org>
Co-authored-by: Jonathan Haas <haasjona@gmail.com>
Co-committed-by: Jonathan Haas <haasjona@gmail.com>
2025-04-12 07:48:39 +00:00

33 lines
843 B
JavaScript

import { expect } from 'chai'
import { Bezier } from '../src/bezier.mjs'
describe('BezierJS', () => {
it('Should find intersections for paths that fail in upstream BezierJS', () => {
const tt1 = new Bezier(
20.294698715209961,
20.116849899291992,
26.718513488769531,
28.516490936279297,
33.345268249511719,
37.4105110168457,
36.240531921386719,
37.736736297607422
)
const tt2 = new Bezier(
43.967803955078125,
30.767040252685547,
43.967803955078125,
31.771089553833008,
35.013500213623047,
32.585041046142578,
23.967803955078125,
32.585041046142578
)
const intersections = tt1.intersects(tt2)
expect(intersections.length).to.equal(1)
const ttReduced = tt1.reduce()
expect(ttReduced.length).to.equal(3)
})
})