TypeError: s.toLowerCase is not a function (#2997)
* Update color.js * fixup * expand test * expand test (again)
This commit is contained in:
@@ -34,7 +34,7 @@ Object.entries(aliases).forEach(([alias, original]) => {
|
||||
// true.
|
||||
const hexColorRegex = /^([\da-f]{3}){1,2}$/i
|
||||
function isHexColor(s = '') {
|
||||
return hexColorRegex.test(s.toLowerCase())
|
||||
return hexColorRegex.test(s)
|
||||
}
|
||||
|
||||
function normalizeColor(color) {
|
||||
|
||||
@@ -5,7 +5,16 @@ const { isHexColor, normalizeColor, toSvgColor } = require('./color')
|
||||
|
||||
test(isHexColor, () => {
|
||||
forCases([given('f00bae'), given('4c1'), given('ABC123')]).expect(true)
|
||||
forCases([given('f00bar'), given(''), given(undefined)]).expect(false)
|
||||
forCases([
|
||||
given('f00bar'),
|
||||
given(''),
|
||||
given(undefined),
|
||||
given(null),
|
||||
given(true),
|
||||
given([]),
|
||||
given({}),
|
||||
given(() => {}),
|
||||
]).expect(false)
|
||||
})
|
||||
|
||||
test(normalizeColor, () => {
|
||||
@@ -17,9 +26,16 @@ test(normalizeColor, () => {
|
||||
given('#ABC123').expect('#abc123')
|
||||
given('papayawhip').expect('papayawhip')
|
||||
given('purple').expect('purple')
|
||||
forCases([given(''), given(undefined), given('not-a-color')]).expect(
|
||||
undefined
|
||||
)
|
||||
forCases([
|
||||
given(''),
|
||||
given('not-a-color'),
|
||||
given(undefined),
|
||||
given(null),
|
||||
given(true),
|
||||
given([]),
|
||||
given({}),
|
||||
given(() => {}),
|
||||
]).expect(undefined)
|
||||
given('lightgray').expect('lightgrey')
|
||||
given('informational').expect('blue')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user