Validating Style Transformation Implementation in dcloudio/uni-app
This test suite validates style transformations in uni-app UTS components, focusing on static and dynamic style binding implementations. It ensures proper compilation of style attributes and their normalization in the virtual DOM.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
dcloudio/uni-app
packages/uni-app-uts/__tests__/android/transforms/transformStyle.spec.ts
import { assert } from '../testUtils'
describe('compiler:static style', () => {
test('template static style', () => {
assert(
`<view style="width:100px;height:60px;background-color:red;opacity:.5;"></view>`,
`createElementVNode(\"view\", utsMapOf({
style: normalizeStyle(utsMapOf({"width":"100px","height":"60px","background-color":"red","opacity":".5"}))
}), null, 4 /* STYLE */)`
)
})
test('template v-bind style', () => {
assert(
`<view :style="{width:'100px', height:'60px', opacity: .5}"></view>`,
`createElementVNode(\"view\", utsMapOf({
style: normalizeStyle(utsMapOf({width:'100px', height:'60px', opacity: .5}))
}), null, 4 /* STYLE */)`
)
})
test('template static style + v-bind style', () => {
assert(
`<view style="width:100px;opacity:.5;" :style="{height: '60px'}"></view>`,
`createElementVNode(\"view\", utsMapOf({
style: normalizeStyle([utsMapOf({"width":"100px","opacity":".5"}), utsMapOf({height: '60px'})])
}), null, 4 /* STYLE */)`
)
})
})