@@ -4,11 +4,12 @@ import { generate } from 'compiler/codegen'
4
4
import { isObject , isFunction , extend } from 'shared/util'
5
5
import { isReservedTag } from 'web/util/index'
6
6
import { baseOptions } from 'web/compiler/options'
7
+ import { BindingTypes } from '../../../../packages/compiler-sfc/src/types'
7
8
8
9
function assertCodegen ( template , generatedCode , ...args ) {
9
- let staticRenderFnCodes = [ ]
10
+ let staticRenderFnCodes : string [ ] = [ ]
10
11
let generateOptions = baseOptions
11
- let proc = null
12
+ let proc : Function | null = null
12
13
let len = args . length
13
14
while ( len -- ) {
14
15
const arg = args [ len ]
@@ -28,7 +29,6 @@ function assertCodegen(template, generatedCode, ...args) {
28
29
expect ( res . staticRenderFns ) . toEqual ( staticRenderFnCodes )
29
30
}
30
31
31
- /* eslint-disable quotes */
32
32
describe ( 'codegen' , ( ) => {
33
33
it ( 'generate directive' , ( ) => {
34
34
assertCodegen (
@@ -624,7 +624,7 @@ describe('codegen', () => {
624
624
expect (
625
625
'Inline-template components must have exactly one child element.'
626
626
) . toHaveBeenWarned ( )
627
- expect ( console . error . mock . calls . length ) . toBe ( 3 )
627
+ expect ( ( console . error as any ) . mock . calls . length ) . toBe ( 3 )
628
628
} )
629
629
630
630
it ( 'generate static trees inside v-for' , ( ) => {
@@ -689,7 +689,7 @@ describe('codegen', () => {
689
689
} )
690
690
691
691
it ( 'not specified ast type' , ( ) => {
692
- const res = generate ( null , baseOptions )
692
+ const res = generate ( undefined , baseOptions )
693
693
expect ( res . render ) . toBe ( `with(this){return _c("div")}` )
694
694
expect ( res . staticRenderFns ) . toEqual ( [ ] )
695
695
} )
@@ -709,5 +709,19 @@ describe('codegen', () => {
709
709
`with(this){return _c('div',[(ok)?_l((1),function(i){return _c('foo',{key:i})}):_e()],2)}`
710
710
)
711
711
} )
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
+ } )
712
727
} )
713
- /* eslint-enable quotes */
0 commit comments