Skip to content

Commit c890403

Browse files
committed
adds more isRgbColor test examples
1 parent 9d0d3b3 commit c890403

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

test/validators.js

+33-4
Original file line numberDiff line numberDiff line change
@@ -4366,6 +4366,7 @@ describe('Validators', () => {
43664366
'rgb(4,4,5%)',
43674367
'rgba(5%,5%,5%)',
43684368
'r g b( 0, 251, 222 )',
4369+
'rgba(255, 255, 255 ,0.2)',
43694370
'r g ba( 0, 251, 222 )',
43704371
],
43714372
});
@@ -4411,10 +4412,37 @@ describe('Validators', () => {
44114412
],
44124413
});
44134414

4414-
// test where strict is false as part of options object
4415+
// test where percent value and strict are false as part of options object
44154416
test({
44164417
validator: 'isRgbColor',
4417-
args: [{ includePercentValues: true, strict: false }],
4418+
args: [{ includePercentValues: false, strict: false }],
4419+
valid: [
4420+
'rgb(5,5,5)',
4421+
'rgba(5,5,5,.3)',
4422+
'rgba(255,255,255,0.2)',
4423+
'rgba(255, 255, 255 ,0.2)',
4424+
],
4425+
invalid: [
4426+
'rgb(4,4,5%)',
4427+
'rgba(5%,5%,5%)',
4428+
'rgba(5% ,5%, 5%)',
4429+
'r g b( 0, 251, 222 )',
4430+
'r g ba( 0, 251, 222 )',
4431+
'rgb(0,0,)',
4432+
'rgb()',
4433+
'rgb(4,4,5%)',
4434+
'rgb(5%,5%,5%)',
4435+
'rgba(3,3,3%,.3)',
4436+
'rgb(101%, 101%, 101%)',
4437+
'rgba(3%,3%,101%,0.3)',
4438+
],
4439+
4440+
});
4441+
4442+
// test where strict is true as part of options object
4443+
test({
4444+
validator: 'isRgbColor',
4445+
args: [{ includePercentValues: true, strict: true }],
44184446
valid: [
44194447
'rgb(5,5,5)',
44204448
'rgba(5,5,5,.3)',
@@ -4426,12 +4454,13 @@ describe('Validators', () => {
44264454
'rgba(255,255,255,0.1)',
44274455
'rgb(5%,5%,5%)',
44284456
'rgba(5%,5%,5%,.3)',
4457+
4458+
],
4459+
invalid: [
44294460
'rgb( 255,255 ,255)',
44304461
'rgba(255, 255, 255, 0.5)',
44314462
'rgb(5%, 5%, 5%)',
44324463
'rgba(255, 255, 255, 0.5)',
4433-
],
4434-
invalid: [
44354464
'rgb(4,4,5%)',
44364465
'rgba(5%,5%,5%)',
44374466
'r g b( 0, 251, 222 )',

0 commit comments

Comments
 (0)