Testing Border Property Transformation Utilities in dcloudio/uni-app
This test suite validates the border property utility functions in uni-nvue-styler, focusing on the transformation and handling of CSS border values across different positions. The tests ensure proper parsing and application of border properties for width, style, and color across all four border positions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
dcloudio/uni-app
packages/uni-nvue-styler/__tests__/test_utils.ts
export type IValue = {
type: string
prop: string
value: string
raws?: any
source?: any
}
export const postionTypes = [
'border-top',
'border-right',
'border-bottom',
'border-left',
]
export const fillBorderPostion = (val: IValue[]): IValue[] => {
const type = ['width', 'style', 'color']
const res: IValue[] = []
val.forEach((item) => {
const currentProp = type.find((t) => item.prop.endsWith(t))!
postionTypes.forEach((postion) => {
res.push({
...item,
type: item.type,
prop: `${postion}-${currentProp}`,
value: item.value,
})
})
})
return res
}