@@ -4,11 +4,12 @@ import { generate } from 'compiler/codegen'
44import { isObject , isFunction , extend } from 'shared/util'
55import { isReservedTag } from 'web/util/index'
66import { baseOptions } from 'web/compiler/options'
7+ import { BindingTypes } from '../../../../packages/compiler-sfc/src/types'
78
89function assertCodegen ( template , generatedCode , ...args ) {
9- let staticRenderFnCodes = [ ]
10+ let staticRenderFnCodes : string [ ] = [ ]
1011 let generateOptions = baseOptions
11- let proc = null
12+ let proc : Function | null = null
1213 let len = args . length
1314 while ( len -- ) {
1415 const arg = args [ len ]
@@ -28,7 +29,6 @@ function assertCodegen(template, generatedCode, ...args) {
2829 expect ( res . staticRenderFns ) . toEqual ( staticRenderFnCodes )
2930}
3031
31- /* eslint-disable quotes */
3232describe ( 'codegen' , ( ) => {
3333 it ( 'generate directive' , ( ) => {
3434 assertCodegen (
@@ -624,7 +624,7 @@ describe('codegen', () => {
624624 expect (
625625 'Inline-template components must have exactly one child element.'
626626 ) . toHaveBeenWarned ( )
627- expect ( console . error . mock . calls . length ) . toBe ( 3 )
627+ expect ( ( console . error as any ) . mock . calls . length ) . toBe ( 3 )
628628 } )
629629
630630 it ( 'generate static trees inside v-for' , ( ) => {
@@ -689,7 +689,7 @@ describe('codegen', () => {
689689 } )
690690
691691 it ( 'not specified ast type' , ( ) => {
692- const res = generate ( null , baseOptions )
692+ const res = generate ( undefined , baseOptions )
693693 expect ( res . render ) . toBe ( `with(this){return _c("div")}` )
694694 expect ( res . staticRenderFns ) . toEqual ( [ ] )
695695 } )
@@ -709,5 +709,19 @@ describe('codegen', () => {
709709 `with(this){return _c('div',[(ok)?_l((1),function(i){return _c('foo',{key:i})}):_e()],2)}`
710710 )
711711 } )
712+
713+ it ( 'component with bindings ' , ( ) => {
714+ const ast = parse ( `<div><Foo/><foo-bar></foo-bar></div>` , baseOptions )
715+ optimize ( ast , baseOptions )
716+ const res = generate ( ast , {
717+ ...baseOptions ,
718+ bindings : {
719+ Foo : BindingTypes . SETUP_CONST ,
720+ FooBar : BindingTypes . SETUP_CONST
721+ }
722+ } )
723+ expect ( res . render ) . toMatchInlineSnapshot (
724+ '"with(this){return _c(\'div\',[_c(Foo),_c(FooBar)],1)}"'
725+ )
726+ } )
712727} )
713- /* eslint-enable quotes */
0 commit comments