-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(is-valid-rgba): pass more valid and less invalid values + test (#31)
* test: add isValidRGBA test * fix(is-valid-rgba): pass more valid and less invalid values - Opacity 1 was invalid. - R, G or B 256-999 were valid.
- Loading branch information
Showing
2 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { expect } from 'chai' | ||
|
||
import { isValidRGBA } from '../src' | ||
|
||
describe('isValidRGBA', function(): void { | ||
const valid = [ | ||
'RGBA(7, 200, 8, .7)', | ||
'RGBA(7, 200, 8, 0.7)', | ||
'RGba(255,255,255,1)', | ||
'Rgba(0,12,123,0.321)', | ||
'rGBa(44, 7, 220,0.92)', | ||
'rGba(210, 50,220, 0.42)', | ||
'rgBa(210,50, 220,0.37)', | ||
'rgbA( 72 , 11 , 123 , 0.21 )', | ||
'rgba(0,0,0,0)', | ||
] | ||
const invalid = [ | ||
' ', | ||
' RGBA(0, 12, 123, 0.3) ', | ||
' RGBA(210,50,220,0)', | ||
'#000000', | ||
'#abc', | ||
'', | ||
'(0,12,123)', | ||
'0', | ||
'0,12,123)', | ||
'5,7,9', | ||
'RGBA(210, 50, 220, 0.77) ', | ||
'false', | ||
'garbage', | ||
'hi rgb(0,12,123)', | ||
'orange', | ||
'rgb 7, 7, 7', | ||
'rgb(0, 12, 123)', | ||
'rgb(0,12,123, 0.2)', | ||
'rgba(0, 0, -1, 0)', | ||
'rgba(0, 0, 0, -1)', | ||
'rgba(0, 0, 0, 1.1)', | ||
'rgba(0, 0, 0, 2)', | ||
'rgba(0, 12, 123, 0.7) :-)', | ||
'rgba(0, 300, 0, 0)', | ||
'rgba(0,1 2,0,0)', | ||
'rgba(0,12,123,0.3', | ||
'rgba(256, 0, 0, 0)', | ||
'rgba(7, 8, 9)', | ||
'rgba(7,8,9)', | ||
'the color is #00AAAA', | ||
'true', | ||
] | ||
|
||
describe('Valid', function(): void { | ||
valid.forEach((color): void => { | ||
it(color, function(): void { | ||
expect(isValidRGBA(color)).to.be.true | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Invalid', function(): void { | ||
invalid.forEach((color): void => { | ||
it(color, function(): void { | ||
expect(isValidRGBA(color)).to.be.false | ||
}) | ||
}) | ||
}) | ||
}) |