mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-18 09:21:04 -04:00
Merge pull request #2356 from adroitwhiz/cast-to-black
Cast malformed color hex strings to RGBA 0,0,0,255 instead of null
This commit is contained in:
commit
7c652246df
2 changed files with 7 additions and 2 deletions
test/unit
|
@ -73,7 +73,7 @@ test('toString', t => {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('toRbgColorList', t => {
|
||||
test('toRgbColorList', t => {
|
||||
// Hex (minimal, see "color" util tests)
|
||||
t.deepEqual(cast.toRgbColorList('#000'), [0, 0, 0]);
|
||||
t.deepEqual(cast.toRgbColorList('#000000'), [0, 0, 0]);
|
||||
|
@ -88,10 +88,11 @@ test('toRbgColorList', t => {
|
|||
// Malformed
|
||||
t.deepEqual(cast.toRgbColorList('ffffff'), [0, 0, 0]);
|
||||
t.deepEqual(cast.toRgbColorList('foobar'), [0, 0, 0]);
|
||||
t.deepEqual(cast.toRgbColorList('#nothex'), [0, 0, 0]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('toRbgColorObject', t => {
|
||||
test('toRgbColorObject', t => {
|
||||
// Hex (minimal, see "color" util tests)
|
||||
t.deepEqual(cast.toRgbColorObject('#000'), {r: 0, g: 0, b: 0});
|
||||
t.deepEqual(cast.toRgbColorObject('#000000'), {r: 0, g: 0, b: 0});
|
||||
|
@ -107,6 +108,7 @@ test('toRbgColorObject', t => {
|
|||
// Malformed
|
||||
t.deepEqual(cast.toRgbColorObject('ffffff'), {a: 255, r: 0, g: 0, b: 0});
|
||||
t.deepEqual(cast.toRgbColorObject('foobar'), {a: 255, r: 0, g: 0, b: 0});
|
||||
t.deepEqual(cast.toRgbColorObject('#nothex'), {a: 255, r: 0, g: 0, b: 0});
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue