From 62e03e6a14df1d56f5bf7f07cae9b588bb8a3dce Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 16 Jun 2022 16:42:43 +0800 Subject: [PATCH] test(mp): mergeVirtualHostAttributes --- .../__tests__/compiler-mp-alipay.spec.js | 35 +++++ .../__tests__/compiler.spec.js | 135 +++++++++++++++++- 2 files changed, 167 insertions(+), 3 deletions(-) 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 997db3ee8d..8e6ff3c3e2 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 9b999e9a47..d9a5ab343b 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', -- GitLab