const compiler = require('../lib') function assertCodegen (template, generatedCode, ...args) { const compiled = compiler.compile(template, { mp: { platform: 'app-plus' }, view: true }) expect(compiled.render).toBe(generatedCode) } /* eslint-disable quotes */ describe('codegen', () => { it('generate directive', () => { assertCodegen( '

', `with(this){return _c('p',{attrs:{"_i":0}})}` ) // extra assertCodegen( '

', `with(this){return _c('p',{attrs:{"_i":0}})}` ) }) it('generate filters', () => { assertCodegen( '
{{ d | e | f }}
', `with(this){return _c('div',{attrs:{"id":_$g(0,'a-id'),"_i":0}},[_v((_$g(0,'t0-0')))])}` ) }) it('generate filters with no arguments', () => { assertCodegen( '
{{ d | e() }}
', `with(this){return _c('div',{attrs:{"_i":0}},[_v((_$g(0,'t0-0')))])}` ) }) it('generate v-for directive', () => { assertCodegen( '
  • ', `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}` ) // iterator syntax assertCodegen( '
  • ', `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,i,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}` ) assertCodegen( '
  • ', `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,key,index,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}` ) // destructuring assertCodegen( '
  • ', `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,$10,$20,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}` ) assertCodegen( '
  • ', `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,key,index,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}` ) // v-for with extra element assertCodegen( '

  • ', `with(this){return _c('div',{attrs:{"_i":0}},[_c('p',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("2-"+$30)}})})],2)}` ) }) it('generate v-if directive', () => { assertCodegen( '

    hello

    ', `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello")]):_e()}` ) }) it('generate v-else directive', () => { assertCodegen( '

    hello

    world

    ', `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):_c('p',{attrs:{"_i":2}},[_v("world")])],1)}` ) }) it('generate v-else-if directive', () => { assertCodegen( '

    hello

    world

    ', `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_e()],1)}` ) }) it('generate v-else-if with v-else directive', () => { assertCodegen( '

    hello

    world

    bye

    ', `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_c('p',{attrs:{"_i":3}},[_v("bye")])],1)}` ) }) it('generate multi v-else-if with v-else directive', () => { assertCodegen( '

    hello

    world

    elseif

    bye

    ', `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):(3)?_c('p',{attrs:{"_i":3}},[_v("elseif")]):_c('p',{attrs:{"_i":4}},[_v("bye")])],1)}` ) }) it('generate ref', () => { assertCodegen( '

    ', `with(this){return _c('p',{ref:"component1",attrs:{"_i":0}})}` ) }) it('generate ref on v-for', () => { assertCodegen( '', `with(this){return _c('ul',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,ref:"component1",refInFor:true,attrs:{"_i":("1-"+$30)}})}),1)}` ) }) it('generate v-bind directive', () => { assertCodegen( '

    ', `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false))}` ) }) it('generate v-bind with prop directive', () => { assertCodegen( '

    ', `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),true))}` ) }) it('generate v-bind directive with sync modifier', () => { assertCodegen( '

    ', `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false,true))}` ) }) it('generate v-model directive', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"test"}})}` ) }) it('generate multiline v-model directive', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"\\n test \\n"}})}` ) }) it('generate multiline v-model directive on custom component', () => { assertCodegen( '', `with(this){return _c('my-component',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function(){},expression:"\\n test \\n"}})}` ) }) it('generate template tag', () => { assertCodegen( '
    ', `with(this){return _c('div',{attrs:{"_i":0}},[[_c('p',{attrs:{"_i":2}},[_v((_$g(2,'t0-0')))])]],2)}` ) }) it('generate single slot', () => { assertCodegen( '
    ', `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",null,{"_i":1})],2)}` ) }) it('generate named slot', () => { assertCodegen( '
    ', `with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}` ) }) it('generate slot fallback content', () => { assertCodegen( '
    hi
    ', `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",[_c('div',{attrs:{"_i":2}},[_v("hi")])],{"_i":1})],2)}` ) }) it('generate slot target', () => { assertCodegen( '

    hello world

    ', `with(this){return _c('p',{attrs:{"slot":"one","_i":0},slot:"one"},[_v("hello world")])}` ) }) it('generate scoped slot', () => { assertCodegen( '', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return [_v((_svm._$g(("1-"+_si),'t0-0')))]}}])})}` ) assertCodegen( '
    {{ bar }}
    ', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0-0')))])}}])})}` ) }) it('generate named scoped slot', () => { assertCodegen( '', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return [_v((_svm._$g(("1-"+_si),'t0-0')))]}}])})}` ) assertCodegen( '
    {{ bar }}
    ', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0-0')))])}}])})}` ) }) it('generate dynamic scoped slot', () => { assertCodegen( '', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:foo,fn:function(bar, _svm, _si){return [_v((_svm._$g(("1-"+_si),'t0-0')))]}}],null,true)})}` ) }) it('generate scoped slot with multiline v-if', () => { assertCodegen( '', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?[_v((_svm._$g(("1-"+_si),'t0-0')))]:undefined}}],null,true)})}` ) assertCodegen( '
    {{ bar }}
    ', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?_c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0-0')))]):_e()}}],null,true)})}` ) }) it('generate scoped slot with new slot syntax', () => { assertCodegen( '', `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([(_$g(1,'i'))?{key:"default",fn:function(bar, _svm, _si){return [_v((_svm._$g(("1-"+_si),'t0-0')))]}}:null],null,true)})}` ) }) it('generate class binding', () => { // static assertCodegen( '

    hello world

    ', `with(this){return _c('p',{staticClass:_$g(0,'sc'),attrs:{"_i":0}},[_v("hello world")])}` ) // dynamic assertCodegen( '

    hello world

    ', `with(this){return _c('p',{class:_$g(0,'c'),attrs:{"_i":0}},[_v("hello world")])}` ) }) it('generate style binding', () => { assertCodegen( '

    hello world

    ', `with(this){return _c('p',{style:(_$g(0,'s')),attrs:{"_i":0}},[_v("hello world")])}` ) }) it('generate v-show directive', () => { assertCodegen( '

    hello world

    ', `with(this){return _c('p',{directives:[{name:"show",rawName:"v-show",value:(_$g(0,'v-show')),expression:"_$g(0,'v-show')"}],attrs:{"_i":0}},[_v("hello world")])}` ) }) it('generate DOM props with v-bind directive', () => { // input + value assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}` ) // non input assertCodegen( '

    ', `with(this){return _c('p',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}` ) }) it('generate attrs with v-bind directive', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"name":_$g(0,'a-name'),"_i":0}})}` ) }) it('generate static attrs', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"name":"field1","_i":0}})}` ) }) it('generate events with v-on directive', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) }) it('generate events with method call', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // empty arguments assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // without semicolon assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // multiple args assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // expression in args assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // tricky symbols in args assertCodegen( ``, `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // function name including a `function` part (#9920) // 2.6.10 暂未修复此 bug // assertCodegen( // '', // `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return functionName()}}})}` // ) }) it('generate events with multiple statements', () => { // normal function assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // function with multiple args assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) }) it('generate events with keycode', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"enter":true})}}})}` ) // multiple keycodes (delete) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"delete":true})}}})}` ) // multiple keycodes (esc) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"esc":true})}}})}` ) // multiple keycodes (space) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"space":true})}}})}` ) // multiple keycodes (chained) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"keydown":function($event){return $handleViewEvent($event,{"enter":true,"delete":true})}}})}` ) // number keycode assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"13":true})}}})}` ) // custom keycode assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"custom":true})}}})}` ) }) it('generate events with generic modifiers', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"stop":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"prevent":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"self":true})}}})}` ) }) // GitHub Issues #5146 it('generate events with generic modifiers and keycode correct order', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"keydown":function($event){return $handleViewEvent($event,{"enter":true,"prevent":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"keydown":function($event){return $handleViewEvent($event,{"enter":true,"stop":true})}}})}` ) }) it('generate events with mouse event modifiers', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"ctrl":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"shift":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"alt":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"meta":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"exact":true})}}})}` ) assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"click":function($event){return $handleViewEvent($event,{"ctrl":true,"exact":true})}}})}` ) }) it('generate events with multiple modifiers', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"stop":true,"prevent":true,"self":true})}}})}` ) }) it('generate events with capture modifier', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"!input":function($event){return $handleViewEvent($event,{"capture":true})}}})}` ) }) it('generate events with once modifier', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"~input":function($event){return $handleViewEvent($event,{"once":true})}}})}` ) }) it('generate events with capture and once modifier', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"~!input":function($event){return $handleViewEvent($event,{"once":true,"capture":true})}}})}` ) }) it('generate events with once and capture modifier', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"~!input":function($event){return $handleViewEvent($event,{"once":true,"capture":true})}}})}` ) }) it('generate events with inline statement', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) }) it('generate events with inline function expression', () => { // normal function assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // normal named function assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // arrow with no args assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // arrow with parens, single arg assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // arrow with parens, multi args assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // arrow with destructuring assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // arrow single arg no parens assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) // with modifiers assertCodegen( ``, `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"keyup":function($event){return $handleViewEvent($event,{"enter":true})}}})}` ) }) // #3893 it('should not treat handler with unexpected whitespace as inline statement', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}` ) }) it('generate unhandled events', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event)}}})}`, ast => { ast.events.input = undefined } ) }) it('generate multiple event handlers', () => { assertCodegen( '', `with(this){return _c('v-uni-input',{attrs:{"_i":0},on:{"input":function($event){return $handleViewEvent($event,{"stop":true})}}})}` ) }) it('generate component', () => { assertCodegen( '

    hi
    ', `with(this){return _c('my-component',{attrs:{"_i":0},on:{"notify":function($event){return $handleViewEvent($event)}}},[_c('div',{attrs:{"_i":1}},[_v("hi")])],1)}` ) }) it('generate svg component with children', () => { assertCodegen( '', `with(this){return _c('svg',{attrs:{"_i":0}},[_c('my-comp',{attrs:{"_i":1}},[_c('circle',{attrs:{"_i":2}})],1)],1)}` ) }) it('generate is attribute', () => { assertCodegen( '
    ', `with(this){return _c("component1",{tag:"div",attrs:{"_i":0}})}` ) assertCodegen( '
    ', `with(this){return _c(_$g(0,'is'),{tag:"div",attrs:{"_i":0}})}` ) // maybe a component and normalize type should be 1 assertCodegen( '
    ', `with(this){return _c('div',{attrs:{"_i":0}},[_c("component1",{tag:"div",attrs:{"_i":1}})],1)}` ) }) it('generate component with inline-template', () => { // have "inline-template'" assertCodegen( '

    hello world

    ', `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('p',{attrs:{"_i":1}},[_c('span',{attrs:{"_i":2}},[_v("hello world")])],1)}},staticRenderFns:[]}})}` ) // "have inline-template attrs, but not having exactly one child element assertCodegen( '

    ', `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('hr',{attrs:{"_i":1}})}},staticRenderFns:[]}})}` ) assertCodegen( '', `with(this){return _c('my-component',{attrs:{"_i":0}})}` ) // have "is" attribute assertCodegen( '
    ', `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('div',{attrs:{"_i":1}})}},staticRenderFns:[]}})}` ) assertCodegen( '
    ', `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0}})}` ) // expect('Inline-template components must have exactly one child element.').toHaveBeenWarned() // expect(console.error.calls.count()).toBe(3) }) it('generate static trees inside v-for', () => { assertCodegen( `

    `, `with(this){return _c('div',{attrs:{"_i":0}},_l((10),function(i,$10,$20,$30){return _c('div',{attrs:{"_i":("1-"+$30)}},[_c('p',{attrs:{"_i":("2-"+$30)}},[_c('span',{attrs:{"_i":("3-"+$30)}})],1)],1)}),1)}` // [`with(this){return _c('p',{attrs:{"_i":("2-"+$i)}},[_c('p',{attrs:{"_i":("3-"+$i)}})])}`] ) }) it('generate component with v-for', () => { // normalize type: 2 assertCodegen( '
    ', `with(this){return _c('div',{attrs:{"_i":0}},[_c('child',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return [_v((_$g(("2-"+$30),'t0-0')))]})],2)}` ) }) // it('generate component with comment', () => { // const options = extend({ // comments: true // }, baseOptions) // const template = '
    ' // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}` // const ast = parse(template, options) // optimize(ast, options) // const res = generate(ast, options) // expect(res.render).toBe(generatedCode) // }) // #6150 // it('generate comments with special characters', () => { // const options = extend({ // comments: true // }, baseOptions) // const template = '
    ' // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}` // const ast = parse(template, options) // optimize(ast, options) // const res = generate(ast, options) // expect(res.render).toBe(generatedCode) // }) // #8041 it('does not squash templates inside v-pre', () => { assertCodegen( '
    ', `with(this){return _c('div',{pre:true,attrs:{"_i":0}},[[_c('p',{pre:true,attrs:{"_i":2}},[_v("{{msg}}")])]],2)}` ) // const template = '
    ' // const generatedCode = `with(this){return _m(0)}` // // const renderFn = `with(this){return _c('p',{pre:true},[_c('template',[_c('p',[_v("{{msg}}")])])],2)}` // const ast = parse(template, baseOptions) // optimize(ast, baseOptions) // const res = generate(ast, baseOptions) // expect(res.render).toBe(generatedCode) // // expect(res.staticRenderFns).toEqual([renderFn]) }) it('not specified ast type', () => { assertCodegen( '', `with(this){return _c("div")}` ) // const res = generate(null, baseOptions) // expect(res.render).toBe(`with(this){return _c("p")}`) // expect(res.staticRenderFns).toEqual([]) }) it('not specified directives option', () => { assertCodegen( '

    hello world

    ', `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello world")]):_e()}`, { // isReservedTag } ) }) // #9142 it('should compile single v-for component inside template', () => { assertCodegen( `
    `, `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_l((1),function(i,$10,$20,$30){return _c('foo',{key:i,attrs:{"_i":("2-"+$30)}})}):_e()],2)}` ) }) }) /* eslint-enable quotes */