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

chore: update __tests__

上级 2aaa1cf9
...@@ -127,6 +127,14 @@ describe('codegen', () => { ...@@ -127,6 +127,14 @@ describe('codegen', () => {
'<view id="aaa" class="bbbb"></view>', '<view id="aaa" class="bbbb"></view>',
`with(this){return _c('view',{staticClass:_$s(0,'sc',"bbbb"),attrs:{"id":"aaa","_i":0}})}` `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 // TODO 后续优化 dataset
// it('generate dataset', () => { // it('generate dataset', () => {
...@@ -140,6 +148,10 @@ describe('codegen', () => { ...@@ -140,6 +148,10 @@ describe('codegen', () => {
'<view data-a="1" :data-b="b"></view>', '<view data-a="1" :data-b="b"></view>',
`with(this){return _c('view',{attrs:{"data-b":_$s(0,'a-data-b',b),"_i":0}})}` `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', () => { it('generate v-if directive', () => {
assertCodegen( assertCodegen(
......
...@@ -69,6 +69,18 @@ describe('codegen', () => { ...@@ -69,6 +69,18 @@ describe('codegen', () => {
`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)}}})}` `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 // TODO 后续优化dataset
// it('generate dataset', () => { // it('generate dataset', () => {
// assertCodegen( // assertCodegen(
...@@ -81,6 +93,10 @@ describe('codegen', () => { ...@@ -81,6 +93,10 @@ describe('codegen', () => {
'<view data-a="1" :data-b="b"></view>', '<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}})}` `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', () => { it('generate v-if directive', () => {
assertCodegen( assertCodegen(
......
...@@ -19,20 +19,7 @@ const scopedPath = path.resolve(__dirname, '../../') ...@@ -19,20 +19,7 @@ const scopedPath = path.resolve(__dirname, '../../')
const compiler = require('../lib') const compiler = require('../lib')
const res = compiler.compile( const res = compiler.compile(
` `
<view> <custom data-a="1" :data-b="b"></custom>
<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>
`, { `, {
miniprogram: true, miniprogram: true,
resourcePath: '/User/fxy/Documents/test.wxml', resourcePath: '/User/fxy/Documents/test.wxml',
...@@ -45,9 +32,9 @@ const res = compiler.compile( ...@@ -45,9 +32,9 @@ const res = compiler.compile(
mp: { mp: {
platform: 'mp-weixin' platform: 'mp-weixin'
}, },
filterModules: ['swipe'] filterModules: ['swipe'],
// service: true, service: true,
// view: true view: true
}) })
console.log(require('util').inspect(res, { console.log(require('util').inspect(res, {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册