From 5d6e8b25effcd3aa2ab5dc03c065047d02fda9f0 Mon Sep 17 00:00:00 2001 From: Dave Lage Date: Sun, 3 Oct 2021 20:05:25 -0400 Subject: [PATCH] fix: Add fromHsla (with decimals) test Support for decimal hsla hue, saturation, and lightness --- test/unit/color.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/unit/color.js b/test/unit/color.js index 145b8c35fb2..aea5ef8693e 100644 --- a/test/unit/color.js +++ b/test/unit/color.js @@ -303,7 +303,18 @@ assert.equal(oColor.toHex(), '180637'); assert.equal(oColor.getAlpha(), 0.2, 'alpha should be set properly'); }); - + + QUnit.test('fromHsla (with decimals)', function(assert) { + assert.ok(typeof fabric.Color.fromHsla === 'function'); + var originalHsla = 'hsla(262.33,80.333%,12.4444%,0.5)'; + var oColor = fabric.Color.fromHsla(originalHsla); + assert.ok(oColor); + assert.ok(oColor instanceof fabric.Color); + assert.equal(oColor.toHsla(), originalHsla); + assert.equal(oColor.toHex(), '180637'); + assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly'); + }); + QUnit.test('fromHsla (with whitespaces)', function(assert) { assert.ok(typeof fabric.Color.fromHsla === 'function'); var originalHsla = 'hsla( 262 , 80% , 12% , 0.2 )';