From 2ae00897e4f2052aae4478eb594008a5c5bb0ff3 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 5 Jun 2020 13:47:44 +0800 Subject: [PATCH] chore: update __tests__ --- .../compiler-app-plus-extra.service.spec.js | 12 +++++++++++ .../compiler-app-plus-extra.view.spec.js | 18 +++++++++++++++- .../uni-template-compiler/__tests__/demo.js | 21 ++++--------------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js index 1d368026..95fad8a6 100644 --- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js @@ -126,6 +126,14 @@ describe('codegen', () => { assertCodegen( '', `with(this){return _c('view',{staticClass:_$s(0,'sc',"bbbb"),attrs:{"id":"aaa","_i":0}})}` + ) + assertCodegen( + '', + `with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}` + ) + assertCodegen( + '', + `with(this){return _c('custom',{attrs:{"id":_$s(0,'a-id',id),"_i":0}})}` ) }) // TODO 后续优化 dataset @@ -139,6 +147,10 @@ describe('codegen', () => { assertCodegen( '', `with(this){return _c('view',{attrs:{"data-b":_$s(0,'a-data-b',b),"_i":0}})}` + ) + assertCodegen( + '', + `with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$s(0,'a-data-b',b),"_i":0}})}` ) }) it('generate v-if directive', () => { diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js index 9adfc872..598a2dd7 100644 --- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js @@ -68,7 +68,19 @@ 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)}}})}` ) - }) + }) + + it('generate staticClass and id', () => { + assertCodegen( + '', + `with(this){return _c('custom',{attrs:{"id":"id","_i":0}})}` + ) + assertCodegen( + '', + `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( '', `with(this){return _c('v-uni-view',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}` + ) + assertCodegen( + '', + `with(this){return _c('custom',{attrs:{"data-a":"1","data-b":_$g(0,'a-data-b'),"_i":0}})}` ) }) it('generate v-if directive', () => { diff --git a/packages/uni-template-compiler/__tests__/demo.js b/packages/uni-template-compiler/__tests__/demo.js index 0eecf9b9..c4d307be 100644 --- a/packages/uni-template-compiler/__tests__/demo.js +++ b/packages/uni-template-compiler/__tests__/demo.js @@ -19,20 +19,7 @@ const scopedPath = path.resolve(__dirname, '../../') const compiler = require('../lib') const res = compiler.compile( ` - - - {{label}} - - - {{label}} - - - {{label}} - - - {{label}} - - + `, { 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, { -- GitLab