utils.test.ts
This file
Path
src/jsx/utils.test.ts
108 lines · 2.8 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 82bdc4d point at it.
4.9.0Yusuke Wadabefore adoption82bdc4d
lines 1–108why, one step back1import { normalizeIntrinsicElementKey, styleObjectForEach } from './utils'23describe('normalizeIntrinsicElementKey', () => {4 test.each`5 key | expected6 ${'className'} | ${'class'}7 ${'htmlFor'} | ${'for'}8 ${'crossOrigin'} | ${'crossorigin'}9 ${'httpEquiv'} | ${'http-equiv'}10 ${'itemProp'} | ${'itemprop'}11 ${'fetchPriority'} | ${'fetchpriority'}12 ${'noModule'} | ${'nomodule'}13 ${'formAction'} | ${'formaction'}14 ${'href'} | ${'href'}15 `('should convert $key to $expected', ({ key, expected }) => {16 expect(normalizeIntrinsicElementKey(key)).toBe(expected)17 })18})1920describe('styleObjectForEach', () => {21 describe('Should output the number as it is, when a number type is passed', () => {22 test.each`23 property24 ${'animationIterationCount'}25 ${'aspectRatio'}26 ${'borderImageOutset'}27 ${'borderImageSlice'}28 ${'borderImageWidth'}29 ${'columnCount'}30 ${'columns'}31 ${'flex'}32 ${'flexGrow'}33 ${'flexPositive'}34 ${'flexShrink'}35 ${'flexNegative'}36 ${'flexOrder'}37 ${'gridArea'}38 ${'gridRow'}39 ${'gridRowEnd'}40 ${'gridRowSpan'}41 ${'gridRowStart'}42 ${'gridColumn'}43 ${'gridColumnEnd'}44 ${'gridColumnSpan'}45 ${'gridColumnStart'}46 ${'fontWeight'}47 ${'lineClamp'}48 ${'lineHeight'}49 ${'opacity'}50 ${'order'}51 ${'orphans'}52 ${'scale'}53 ${'tabSize'}54 ${'widows'}55 ${'zIndex'}56 ${'zoom'}57 ${'fillOpacity'}58 ${'floodOpacity'}59 ${'stopOpacity'}60 ${'strokeDasharray'}61 ${'strokeDashoffset'}62 ${'strokeMiterlimit'}63 ${'strokeOpacity'}64 ${'strokeWidth'}65 `('$property', ({ property }) => {66 const fn = vi.fn()67 styleObjectForEach({ [property]: 1 }, fn)68 expect(fn).toBeCalledWith(69 property.replace(/[A-Z]/g, (m: string) => `-${m.toLowerCase()}`),70 '1'71 )72 })73 })74 describe('Should output with px suffix, when a number type is passed', () => {75 test.each`76 property77 ${'borderBottomWidth'}78 ${'borderLeftWidth'}79 ${'borderRightWidth'}80 ${'borderTopWidth'}81 ${'borderWidth'}82 ${'bottom'}83 ${'fontSize'}84 ${'height'}85 ${'left'}86 ${'margin'}87 ${'marginBottom'}88 ${'marginLeft'}89 ${'marginRight'}90 ${'marginTop'}91 ${'padding'}92 ${'paddingBottom'}93 ${'paddingLeft'}94 ${'paddingRight'}95 ${'paddingTop'}96 ${'right'}97 ${'top'}98 ${'width'}99 `('$property', ({ property }) => {100 const fn = vi.fn()101 styleObjectForEach({ [property]: 1 }, fn)102 expect(fn).toBeCalledWith(103 property.replace(/[A-Z]/g, (m: string) => `-${m.toLowerCase()}`),104 '1px'105 )106 })107 })108})