const compiler = require('../lib') function assertCodegen (template, templateCode, renderCode = 'with(this){}', options = {}) { const res = compiler.compile(template, { resourcePath: 'test.wxml', mp: Object.assign({ minified: true, isTest: true, platform: 'mp-toutiao' }, options) }) expect(res.template).toBe(templateCode) expect(res.render).toBe(renderCode) } describe('mp:compiler-mp-toutiao', () => { it('generate v-for directive', () => { assertCodegen( '', '' ) }) it('generate ref', () => { assertCodegen( '', '' ) }) it('generate class binding', () => { assertCodegen( '
1
', '1' ) assertCodegen( '

2

', '2' ) assertCodegen( '

3

', '3' ) assertCodegen( '

4

', '4' ) assertCodegen( '

5

', '5' ) assertCodegen( '
6
', '6' ) // assertCodegen( // `
6
`, // `6`, // `with(this){var c0=__get_class(computedClassObject,"container");$mp.data=Object.assign({},{$root:{c0:c0}})}` // ) assertCodegen( '

7

', '7' ) assertCodegen( '

8

', '8' ) assertCodegen( '

9

', '9' ) }) })