提交 2ae00897 编写于 作者: fxy060608's avatar fxy060608

chore: update __tests__

上级 2aaa1cf9
......@@ -126,6 +126,14 @@ describe('codegen', () => {
assertCodegen(
'<view id="aaa" class="bbbb"></view>',
`with(this){return _c('view',{staticClass:_$s(0,'sc',"bbbb"),attrs:{"id":"aaa","_i":0}})}`
)
assertCodegen(
'<custom id="id"></custom>',
`with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}`
)
assertCodegen(
'<custom :id="id"></custom>',
`with(this){return _c('custom',{attrs:{"id":_$s(0,'a-id',id),"_i":0}})}`
)
})
// TODO 后续优化 dataset
......@@ -139,6 +147,10 @@ describe('codegen', () => {
assertCodegen(
'<view data-a="1" :data-b="b"></view>',
`with(this){return _c('view',{attrs:{"data-b":_$s(0,'a-data-b',b),"_i":0}})}`
)
assertCodegen(
'<custom data-a="1" :data-b="b"></custom>',
`with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$s(0,'a-data-b',b),"_i":0}})}`
)
})
it('generate v-if directive', () => {
......
......@@ -68,7 +68,19 @@ describe('codegen', () => {
'<p :change:prop="swipe.sizeReady" :prop="pos" @touchstart="swipe.touchstart" @touchmove="swipe.touchmove" @touchend="swipe.touchend" @change="change"></p>',
`with(this){return _c('p',{wxsProps:{"change:prop":"pos"},attrs:{"change:prop":swipe.sizeReady,"prop":_$gc(0,'change:pos'),"_i":0},on:{"touchstart":function($event){$event = $handleWxsEvent($event);swipe.touchstart($event, $getComponentDescriptor())},"touchmove":function($event){$event = $handleWxsEvent($event);swipe.touchmove($event, $getComponentDescriptor())},"touchend":function($event){$event = $handleWxsEvent($event);swipe.touchend($event, $getComponentDescriptor())},"change":function($event){return $handleViewEvent($event)}}})}`
)
})
})
it('generate staticClass and id', () => {
assertCodegen(
'<custom id="id"></custom>',
`with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}`
)
assertCodegen(
'<custom :id="id"></custom>',
`with(this){return _c('custom',{attrs:{"id":_$g(0,'a-id'),"_i":0}})}`
)
})
// TODO 后续优化dataset
// it('generate dataset', () => {
// assertCodegen(
......@@ -80,6 +92,10 @@ describe('codegen', () => {
assertCodegen(
'<view data-a="1" :data-b="b"></view>',
`with(this){return _c('v-uni-view',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}`
)
assertCodegen(
'<custom data-a="1" :data-b="b"></custom>',
`with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}`
)
})
it('generate v-if directive', () => {
......
......@@ -19,20 +19,7 @@ const scopedPath = path.resolve(__dirname, '../../')
const compiler = require('../lib')
const res = compiler.compile(
`
<view>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view>{{label}}</view>
</slot-comp>
<slot-comp v-slot:test="{label}">
<view class="red">{{label}}</view>
</slot-comp>
</view>
<custom data-a="1" :data-b="b"></custom>
`, {
miniprogram: true,
resourcePath: '/User/fxy/Documents/test.wxml',
......@@ -45,9 +32,9 @@ const res = compiler.compile(
mp: {
platform: 'mp-weixin'
},
filterModules: ['swipe']
// service: true,
// view: true
filterModules: ['swipe'],
service: true,
view: true
})
console.log(require('util').inspect(res, {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册