Skip to content

Commit a26edde

Browse files
authored
add testcase for tinycolor.random() (#258)
1 parent 43b3456 commit a26edde

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ Deno.test("Cloning color", function () {
104104
"original color was not changed by cloned color change"
105105
);
106106
});
107+
Deno.test("Random color", function () {
108+
var randomColor = tinycolor.random();
109+
assertEquals(randomColor.getAlpha(), 1);
110+
assertEquals(randomColor.getFormat(), "prgb");
111+
112+
randomColor.setAlpha(0.5);
113+
assertEquals(randomColor.toHex8String().slice(-2), "80");
114+
});
107115

108116
// Taken from convertWikipediaColors.html
109117
var conversions = [
@@ -450,7 +458,7 @@ Deno.test("HSL parsing", function () {
450458
"to hsl"
451459
);
452460
assertEquals(
453-
tinycolor({ h: 251, s: 100, l: 0.38, a: .5 }).toHslString(),
461+
tinycolor({ h: 251, s: 100, l: 0.38, a: 0.5 }).toHslString(),
454462
"hsla(251, 100%, 38%, 0.5)",
455463
"to hsla"
456464
);

0 commit comments

Comments
 (0)