From 6ad7e851447a5c98f7940d2673379fe8779df8da Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Sat, 4 May 2024 14:42:46 +0100 Subject: [PATCH] textWrap() parameter validation uses FES instead of throwing error --- src/typography/attributes.js | 5 ++--- test/unit/typography/attributes.js | 5 ----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/typography/attributes.js b/src/typography/attributes.js index f5242f415b..3960ad53bc 100644 --- a/src/typography/attributes.js +++ b/src/typography/attributes.js @@ -539,9 +539,8 @@ p5.prototype._updateTextMetrics = function() { * */ p5.prototype.textWrap = function(wrapStyle) { - if (wrapStyle !== 'WORD' && wrapStyle !== 'CHAR') { - throw 'Error: textWrap accepts only WORD or CHAR'; - } + p5._validateParameters('textWrap', [wrapStyle]); + return this._renderer.textWrap(wrapStyle); }; diff --git a/test/unit/typography/attributes.js b/test/unit/typography/attributes.js index cb234f2a5b..ebfa6b552f 100644 --- a/test/unit/typography/attributes.js +++ b/test/unit/typography/attributes.js @@ -113,11 +113,6 @@ suite('Typography Attributes', function() { }); suite('p5.prototype.textWrap', function() { - test('should throw error for non-constant input', function() { - expect(function() { - myp5.textWrap('NO-WRAP'); - }).to.throw('Error: textWrap accepts only WORD or CHAR'); - }); test('returns textWrap text attribute', function() { assert.strictEqual(myp5.textWrap(myp5.WORD), myp5.WORD); });