Skip to content

Commit a13b25b

Browse files
committed
fix: handle null and non-object options in isHexColor with 100% coverage
1 parent e5a82c2 commit a13b25b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/validators.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,6 +5042,18 @@ describe('Validators', () => {
50425042
'',
50435043
],
50445044
});
5045+
test({
5046+
validator: 'isHexColor',
5047+
args: [null],
5048+
valid: ['#fff', '#000000', '123'],
5049+
invalid: ['not-a-color'],
5050+
});
5051+
test({
5052+
validator: 'isHexColor',
5053+
args: [123],
5054+
valid: ['#fff', '#000000', '123', 'abc'],
5055+
invalid: ['gray', 'not-a-color'],
5056+
});
50455057
const validColors = ['#ff0034', '#CCCCCC'].filter(validator.isHexColor);
50465058
assert.strictEqual(validColors.length, 2);
50475059
});

0 commit comments

Comments
 (0)