Skip to content

Commit 4cc8320

Browse files
committed
wip(x): 补充测试用例
1 parent 5950243 commit 4cc8320

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

packages/uni-mp-xhs/__tests__/component.spec.ts

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { assert } from './testUtils'
2+
import { transformMPBuiltInTag } from '../src/compiler/transforms/transformMPBuiltInTag'
23

34
describe('mp-xhs: transform component', () => {
45
test('lazy element: textarea', () => {
@@ -86,3 +87,158 @@ describe('mp-xhs: transform component', () => {
8687
)
8788
})
8889
})
90+
91+
describe('mp-xhs: transform component x', () => {
92+
test('checkbox prop rename', () => {
93+
assert(
94+
`<checkbox fore-color="#FF0000"/>`,
95+
`<checkbox color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
96+
`(_ctx, _cache) => { "raw js"
97+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
98+
return __returned__
99+
}`,
100+
{
101+
isX: true,
102+
nodeTransforms: [transformMPBuiltInTag],
103+
}
104+
)
105+
106+
assert(
107+
`<checkbox fore-color="#FF0000" checked/>`,
108+
`<checkbox color="#FF0000" checked style="{{'--status-bar-height:' + a}}"/>`,
109+
`(_ctx, _cache) => { "raw js"
110+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
111+
return __returned__
112+
}`,
113+
{
114+
isX: true,
115+
nodeTransforms: [transformMPBuiltInTag],
116+
}
117+
)
118+
})
119+
120+
test('radio prop rename', () => {
121+
assert(
122+
`<radio active-background-color="#FF0000"/>`,
123+
`<radio color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
124+
`(_ctx, _cache) => { "raw js"
125+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
126+
return __returned__
127+
}`,
128+
{
129+
isX: true,
130+
nodeTransforms: [transformMPBuiltInTag],
131+
}
132+
)
133+
134+
assert(
135+
`<radio color="#FF0000"/>`,
136+
`<radio color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
137+
`(_ctx, _cache) => { "raw js"
138+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
139+
return __returned__
140+
}`,
141+
{
142+
isX: true,
143+
nodeTransforms: [transformMPBuiltInTag],
144+
}
145+
)
146+
})
147+
148+
test('slider prop rename', () => {
149+
assert(
150+
`<slider active-background-color="#FF0000" fore-color="#00FF00"/>`,
151+
`<slider active-color="#FF0000" block-color="#00FF00" style="{{'--status-bar-height:' + a}}"/>`,
152+
`(_ctx, _cache) => { "raw js"
153+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
154+
return __returned__
155+
}`,
156+
{
157+
isX: true,
158+
nodeTransforms: [transformMPBuiltInTag],
159+
}
160+
)
161+
162+
assert(
163+
`<slider active-background-color="#FF0000"/>`,
164+
`<slider active-color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
165+
`(_ctx, _cache) => { "raw js"
166+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
167+
return __returned__
168+
}`,
169+
{
170+
isX: true,
171+
nodeTransforms: [transformMPBuiltInTag],
172+
}
173+
)
174+
175+
assert(
176+
`<slider fore-color="#00FF00"/>`,
177+
`<slider block-color="#00FF00" style="{{'--status-bar-height:' + a}}"/>`,
178+
`(_ctx, _cache) => { "raw js"
179+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
180+
return __returned__
181+
}`,
182+
{
183+
isX: true,
184+
nodeTransforms: [transformMPBuiltInTag],
185+
}
186+
)
187+
})
188+
189+
test('switch prop rename', () => {
190+
assert(
191+
`<switch active-background-color="#FF0000"/>`,
192+
`<switch color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
193+
`(_ctx, _cache) => { "raw js"
194+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
195+
return __returned__
196+
}`,
197+
{
198+
isX: true,
199+
nodeTransforms: [transformMPBuiltInTag],
200+
}
201+
)
202+
203+
assert(
204+
`<switch color="#FF0000"/>`,
205+
`<switch color="#FF0000" style="{{'--status-bar-height:' + a}}"/>`,
206+
`(_ctx, _cache) => { "raw js"
207+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
208+
return __returned__
209+
}`,
210+
{
211+
isX: true,
212+
nodeTransforms: [transformMPBuiltInTag],
213+
}
214+
)
215+
})
216+
217+
test('tag rename: list-view to scroll-view', () => {
218+
assert(
219+
`<list-view/>`,
220+
`<scroll-view style="{{'--status-bar-height:' + a}}"/>`,
221+
`(_ctx, _cache) => { "raw js"
222+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
223+
return __returned__
224+
}`,
225+
{
226+
isX: true,
227+
nodeTransforms: [transformMPBuiltInTag],
228+
}
229+
)
230+
231+
assert(
232+
`<list-view scroll-y="true"/>`,
233+
`<scroll-view scroll-y="true" style="{{'--status-bar-height:' + a}}"/>`,
234+
`(_ctx, _cache) => { "raw js"
235+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
236+
return __returned__
237+
}`,
238+
{
239+
isX: true,
240+
nodeTransforms: [transformMPBuiltInTag],
241+
}
242+
)
243+
})
244+
})

0 commit comments

Comments
 (0)