diff --git a/packages/core/src/part.js b/packages/core/src/part.js index 5207f41ea47..653d251a532 100644 --- a/packages/core/src/part.js +++ b/packages/core/src/part.js @@ -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] } diff --git a/packages/core/tests/part.test.js b/packages/core/tests/part.test.js index 0456ca7d285..1cfec636616 100644 --- a/packages/core/tests/part.test.js +++ b/packages/core/tests/part.test.js @@ -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", () => {