Skip to content

Commit

Permalink
Add tests for #187
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed Feb 23, 2023
1 parent 063f76b commit 3af9660
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/rgb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,27 @@ tape('formatCss', t => {
);
t.end();
});

/*
See: https://emnudge.dev/blog/perfect-rgb-regex/
*/
tape('exotic species', t => {
t.equal(
formatCss(rgb('rgb(1-2-3)')),
'color(srgb 0.00392156862745098 -0.00784313725490196 -0.011764705882352941)'
);
t.equal(
formatCss(rgb('rgb(1-.2.3)')),
'color(srgb 0.00392156862745098 -0.0007843137254901962 0.001176470588235294)'
);
t.equal(
formatCss(rgb('rgb(1 .2.3)')),
'color(srgb 0.00392156862745098 0.0007843137254901962 0.001176470588235294)'
);
t.equal(
formatCss(rgb('rgb(.1.2.3)')),
'color(srgb 0.0003921568627450981 0.0007843137254901962 0.001176470588235294)'
);
t.equal(formatCss(rgb('rgb(1.2.3)')), undefined);
t.end();
});

0 comments on commit 3af9660

Please sign in to comment.