Skip to content

Commit 3c6ac9f

Browse files
committed
test(x-mp): 更新测试用例
1 parent c5943a8 commit 3c6ac9f

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

packages/uni-mp-compiler/__tests__/root.spec.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ describe('compiler: root', () => {
109109
}`,
110110
{ isX: true }
111111
)
112-
113112
assert(
114113
`<custom><view/></custom>`,
115114
`<custom u-s="{{['d']}}" u-i="2a9ec0b0-0"><view/></custom>`,
@@ -119,7 +118,6 @@ describe('compiler: root', () => {
119118
}`,
120119
{ isX: true }
121120
)
122-
123121
assert(
124122
`<custom></custom><view/>`,
125123
`<custom u-i="2a9ec0b0-0"></custom><view style="{{'--status-bar-height:' + a}}"/>`,
@@ -129,13 +127,30 @@ describe('compiler: root', () => {
129127
}`,
130128
{ isX: true }
131129
)
132-
133130
assert(
134131
`<custom></custom><view><custom/></view>`,
135132
`<custom u-i="2a9ec0b0-0"></custom><view style="{{'--status-bar-height:' + a}}"><custom u-i="2a9ec0b0-1"/></view>`,
136133
`(_ctx, _cache) => { "raw js"
137134
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\` }
138135
return __returned__
136+
}`,
137+
{ isX: true }
138+
)
139+
assert(
140+
`<custom>test</custom>`,
141+
`<custom u-s="{{['d']}}" u-i="2a9ec0b0-0">test</custom>`,
142+
`(_ctx, _cache) => { "raw js"
143+
const __returned__ = {}
144+
return __returned__
145+
}`,
146+
{ isX: true }
147+
)
148+
assert(
149+
`<custom><template #name><view>test</view></template></custom>`,
150+
`<custom u-s="{{['name']}}" u-i="2a9ec0b0-0"><view slot="name">test</view></custom>`,
151+
`(_ctx, _cache) => { "raw js"
152+
const __returned__ = {}
153+
return __returned__
139154
}`,
140155
{ isX: true }
141156
)
@@ -204,17 +219,35 @@ describe('compiler: root', () => {
204219
`(_ctx, _cache) => { "raw js"
205220
const __returned__ = {}
206221
return __returned__
222+
}`,
223+
{ isX: true }
224+
)
225+
assert(
226+
`<view>test</view><view><slot name="s1"><view><view>test1</view></view><view>test2</view></slot></view>`,
227+
`<view style="{{'--status-bar-height:' + a}}">test</view><view style="{{'--status-bar-height:' + b}}"><block wx:if="{{$slots.s1}}"><slot name="s1"></slot></block><block wx:else><view><view>test1</view></view><view>test2</view></block></view>`,
228+
`(_ctx, _cache) => { "raw js"
229+
const __returned__ = { a: \`\${_ctx.u_s_b_h}px\`, b: \`\${_ctx.u_s_b_h}px\` }
230+
return __returned__
207231
}`,
208232
{ isX: true }
209233
)
210234
})
211235
test('v-for', () => {
212236
assert(
213-
`<template v-for="item in list"><view>item -- {{ item }}</view></template>`,
214-
`<block wx:for="{{a}}" wx:for-item="item"><view style="{{'--status-bar-height:' + b}}">item -- {{item.a}}</view></block>`,
237+
`<template v-for="item in list"><view><text>item -- {{ item }}</text></view></template>`,
238+
`<block wx:for="{{a}}" wx:for-item="item"><view style="{{'--status-bar-height:' + b}}"><text>item -- {{item.a}}</text></view></block>`,
215239
`(_ctx, _cache) => { "raw js"
216240
const __returned__ = { a: _f(_ctx.list, (item, k0, i0) => { return { a: _t(item) }; }), b: \`\${_ctx.u_s_b_h}px\` }
217241
return __returned__
242+
}`,
243+
{ isX: true }
244+
)
245+
assert(
246+
`<template v-for="item in list"><view>item -- {{ item }}</view></template><view><text>test</text></view>`,
247+
`<block wx:for="{{a}}" wx:for-item="item"><view style="{{'--status-bar-height:' + b}}">item -- {{item.a}}</view></block><view style="{{'--status-bar-height:' + c}}"><text>test</text></view>`,
248+
`(_ctx, _cache) => { "raw js"
249+
const __returned__ = { a: _f(_ctx.list, (item, k0, i0) => { return { a: _t(item) }; }), b: \`\${_ctx.u_s_b_h}px\`, c: \`\${_ctx.u_s_b_h}px\` }
250+
return __returned__
218251
}`,
219252
{ isX: true }
220253
)

0 commit comments

Comments
 (0)