import { normalizeIntrinsicElementKey, styleObjectForEach } from './utils' describe('normalizeIntrinsicElementKey', () => { test.each` key | expected ${'className'} | ${'class'} ${'htmlFor'} | ${'for'} ${'crossOrigin'} | ${'crossorigin'} ${'httpEquiv'} | ${'http-equiv'} ${'itemProp'} | ${'itemprop'} ${'fetchPriority'} | ${'fetchpriority'} ${'noModule'} | ${'nomodule'} ${'formAction'} | ${'formaction'} ${'href'} | ${'href'} `('should convert $key to $expected', ({ key, expected }) => { expect(normalizeIntrinsicElementKey(key)).toBe(expected) }) }) describe('styleObjectForEach', () => { describe('Should output the number as it is, when a number type is passed', () => { test.each` property ${'animationIterationCount'} ${'aspectRatio'} ${'borderImageOutset'} ${'borderImageSlice'} ${'borderImageWidth'} ${'columnCount'} ${'columns'} ${'flex'} ${'flexGrow'} ${'flexPositive'} ${'flexShrink'} ${'flexNegative'} ${'flexOrder'} ${'gridArea'} ${'gridRow'} ${'gridRowEnd'} ${'gridRowSpan'} ${'gridRowStart'} ${'gridColumn'} ${'gridColumnEnd'} ${'gridColumnSpan'} ${'gridColumnStart'} ${'fontWeight'} ${'lineClamp'} ${'lineHeight'} ${'opacity'} ${'order'} ${'orphans'} ${'scale'} ${'tabSize'} ${'widows'} ${'zIndex'} ${'zoom'} ${'fillOpacity'} ${'floodOpacity'} ${'stopOpacity'} ${'strokeDasharray'} ${'strokeDashoffset'} ${'strokeMiterlimit'} ${'strokeOpacity'} ${'strokeWidth'} `('$property', ({ property }) => { const fn = vi.fn() styleObjectForEach({ [property]: 1 }, fn) expect(fn).toBeCalledWith( property.replace(/[A-Z]/g, (m: string) => `-${m.toLowerCase()}`), '1' ) }) }) describe('Should output with px suffix, when a number type is passed', () => { test.each` property ${'borderBottomWidth'} ${'borderLeftWidth'} ${'borderRightWidth'} ${'borderTopWidth'} ${'borderWidth'} ${'bottom'} ${'fontSize'} ${'height'} ${'left'} ${'margin'} ${'marginBottom'} ${'marginLeft'} ${'marginRight'} ${'marginTop'} ${'padding'} ${'paddingBottom'} ${'paddingLeft'} ${'paddingRight'} ${'paddingTop'} ${'right'} ${'top'} ${'width'} `('$property', ({ property }) => { const fn = vi.fn() styleObjectForEach({ [property]: 1 }, fn) expect(fn).toBeCalledWith( property.replace(/[A-Z]/g, (m: string) => `-${m.toLowerCase()}`), '1px' ) }) }) })