diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js index 997db3ee8d03d763181dcd7a2be714c18392c1d5..8e6ff3c3e21418b28b166e03d6bae00b49316d0f 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js @@ -204,6 +204,41 @@ describe('mp:compiler-mp-alipay', () => { ) }) + it('generate attrs with mergeVirtualHostAttributes', () => { + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + }) + it('generate getPhoneNumber', () => { assertCodegen( '', diff --git a/packages/uni-template-compiler/__tests__/compiler.spec.js b/packages/uni-template-compiler/__tests__/compiler.spec.js index 9b999e9a47b6b5e51a184403931a8e03a137f900..d9a5ab343b42dffaeba797283b9817531adbbd96 100644 --- a/packages/uni-template-compiler/__tests__/compiler.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler.spec.js @@ -1,13 +1,13 @@ const compiler = require('../lib') -function assertCodegen (template, templateCode, renderCode = 'with(this){}') { +function assertCodegen (template, templateCode, renderCode = 'with(this){}', options = {}) { const res = compiler.compile(template, { resourcePath: 'test.wxml', - mp: { + mp: Object.assign({ minified: true, isTest: true, platform: 'mp-weixin' - } + }, options) }) expect(res.template).toBe(templateCode) @@ -253,6 +253,108 @@ describe('mp:compiler', () => { // ) }) + it('generate attrs with mergeVirtualHostAttributes', () => { + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + }) + + it('generate class with mergeVirtualHostAttributes', () => { + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + }) + it('generate staticStyle', () => { assertCodegen( 'hello world', @@ -272,6 +374,33 @@ describe('mp:compiler', () => { // ) }) + it('generate style with mergeVirtualHostAttributes', () => { + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + assertCodegen( + 'hello world', + 'hello world', + 'with(this){}', + { + mergeVirtualHostAttributes: true + } + ) + }) + it('generate v-show directive', () => { assertCodegen( 'hello world',