Skip to content

Commit

Permalink
fix: Add fromHsla (with decimals) test
Browse files Browse the repository at this point in the history
Support for decimal hsla hue, saturation, and lightness
  • Loading branch information
rockerBOO committed May 2, 2022
1 parent cec3b12 commit 5d6e8b2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/unit/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )';
Expand Down

0 comments on commit 5d6e8b2

Please sign in to comment.