Color / add an isStringColor utility function

This commit is contained in:
Olivier Guyot
2019-10-22 16:03:34 +02:00
parent a0b271a812
commit 56faf4c3ad
2 changed files with 26 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import {
asArray,
asString,
fromString,
isStringColor,
normalize,
toString
} from '../../../src/ol/color.js';
@@ -159,4 +160,18 @@ describe('ol.color', function() {
});
});
describe('isValid()', function() {
it('correctly detects valid colors', function() {
expect(isStringColor('rgba(1,3,4,0.4)')).to.be(true);
expect(isStringColor('rgb(1,3,4)')).to.be(true);
expect(isStringColor('lightgreen')).to.be(true);
expect(isStringColor('yellow')).to.be(true);
expect(isStringColor('GREEN')).to.be(true);
expect(isStringColor('notacolor')).to.be(false);
expect(isStringColor('red_')).to.be(false);
});
});
});