1
0
Fork 0

feat(core): Add ability to remove cutOnFold

This commit is contained in:
joostdecock 2022-07-31 12:17:51 +02:00
parent 5c486382ec
commit 8d1bc3c516
2 changed files with 8 additions and 2 deletions

View file

@ -400,7 +400,11 @@ Part.prototype.setGrain = function (grain=false) {
}
/** Chainable way to add the cutOnFold info */
Part.prototype.setCutOnFold = function (p1=false, p2=false) {
Part.prototype.setCutOnFold = function (p1, p2) {
if (p1 === false && typeof p2 === 'undefined') {
delete this.cut.cutOnFold
return this
}
if (p1 instanceof Point && p2 instanceof Point) {
this.cut.cutOnFold = [p1, p2]
}

View file

@ -376,7 +376,7 @@ it("Should raise an error when calling part.setGrain() with a value that is not
expect(pattern.events.error[0]).to.equal('Called part.setGrain() with a value that is not a number')
});
it("Should set the cutOnFold", () => {
it("Should set and then remove the cutOnFold", () => {
let pattern = new freesewing.Pattern();
let part = new pattern.Part();
const { Point } = part.shorthand()
@ -385,6 +385,8 @@ it("Should set the cutOnFold", () => {
expect(part.cut.cutOnFold[0].y).to.equal(3)
expect(part.cut.cutOnFold[1].x).to.equal(100)
expect(part.cut.cutOnFold[1].y).to.equal(200)
part.setCutOnFold(false)
expect(typeof part.cut.cutOnFold).to.equal('undefined')
});
it("Should raise an error when setting the cutOnFold with a non-Point value", () => {