@@ -446,7 +446,7 @@ describe('api: options', () => {
446
446
calls . push ( 'mixinA created' )
447
447
expect ( this . a ) . toBe ( 1 )
448
448
expect ( this . b ) . toBe ( 2 )
449
- expect ( this . c ) . toBe ( 3 )
449
+ expect ( this . c ) . toBe ( 4 )
450
450
} ,
451
451
mounted ( ) {
452
452
calls . push ( 'mixinA mounted' )
@@ -468,7 +468,7 @@ describe('api: options', () => {
468
468
expect ( this . a ) . toBe ( 1 )
469
469
expect ( this . b ) . toBe ( 2 )
470
470
expect ( this . bP ) . toBeUndefined ( )
471
- expect ( this . c ) . toBe ( 3 )
471
+ expect ( this . c ) . toBe ( 4 )
472
472
expect ( this . cP1 ) . toBeUndefined ( )
473
473
} ,
474
474
mounted ( ) {
@@ -484,7 +484,8 @@ describe('api: options', () => {
484
484
} ,
485
485
created ( ) {
486
486
calls . push ( 'mixinC created' )
487
- expect ( this . c ) . toBe ( 3 )
487
+ // component data() should overwrite mixin field with same key
488
+ expect ( this . c ) . toBe ( 4 )
488
489
expect ( this . cP1 ) . toBeUndefined ( )
489
490
} ,
490
491
mounted ( ) {
@@ -498,6 +499,7 @@ describe('api: options', () => {
498
499
mixins : [ defineComponent ( mixinA ) , defineComponent ( mixinB ) , mixinC ] ,
499
500
data ( ) {
500
501
return {
502
+ c : 4 ,
501
503
z : 4
502
504
}
503
505
} ,
@@ -506,7 +508,7 @@ describe('api: options', () => {
506
508
expect ( this . a ) . toBe ( 1 )
507
509
expect ( this . b ) . toBe ( 2 )
508
510
expect ( this . bP ) . toBeUndefined ( )
509
- expect ( this . c ) . toBe ( 3 )
511
+ expect ( this . c ) . toBe ( 4 )
510
512
expect ( this . cP2 ) . toBeUndefined ( )
511
513
expect ( this . z ) . toBe ( 4 )
512
514
} ,
@@ -517,7 +519,7 @@ describe('api: options', () => {
517
519
return `${ this . a } ${ this . b } ${ this . c } `
518
520
}
519
521
} )
520
- expect ( renderToString ( h ( Comp ) ) ) . toBe ( `123 ` )
522
+ expect ( renderToString ( h ( Comp ) ) ) . toBe ( `124 ` )
521
523
expect ( calls ) . toEqual ( [
522
524
'mixinA created' ,
523
525
'mixinB created' ,
@@ -546,7 +548,8 @@ describe('api: options', () => {
546
548
const Base = {
547
549
data ( ) {
548
550
return {
549
- a : 1
551
+ a : 1 ,
552
+ b : 1
550
553
}
551
554
} ,
552
555
methods : {
@@ -582,7 +585,8 @@ describe('api: options', () => {
582
585
const Base = {
583
586
data ( ) {
584
587
return {
585
- a : 1
588
+ a : 1 ,
589
+ x : 'base'
586
590
}
587
591
} ,
588
592
methods : {
@@ -595,22 +599,23 @@ describe('api: options', () => {
595
599
calls . push ( 'base' )
596
600
}
597
601
}
598
- const Base2 = {
602
+ const Mixin = {
599
603
data ( ) {
600
604
return {
601
- b : true
605
+ b : true ,
606
+ x : 'mixin'
602
607
}
603
608
} ,
604
609
mounted ( this : any ) {
605
610
expect ( this . a ) . toBe ( 1 )
606
611
expect ( this . b ) . toBeTruthy ( )
607
612
expect ( this . c ) . toBe ( 2 )
608
- calls . push ( 'base2 ' )
613
+ calls . push ( 'mixin ' )
609
614
}
610
615
}
611
616
const Comp = defineComponent ( {
612
617
extends : defineComponent ( Base ) ,
613
- mixins : [ defineComponent ( Base2 ) ] ,
618
+ mixins : [ defineComponent ( Mixin ) ] ,
614
619
data ( ) {
615
620
return {
616
621
c : 2
@@ -620,12 +625,12 @@ describe('api: options', () => {
620
625
calls . push ( 'comp' )
621
626
} ,
622
627
render ( ) {
623
- return `${ this . a } ${ this . b } ${ this . c } `
628
+ return `${ this . a } ${ this . b } ${ this . c } ${ this . x } `
624
629
}
625
630
} )
626
631
627
- expect ( renderToString ( h ( Comp ) ) ) . toBe ( `1true2 ` )
628
- expect ( calls ) . toEqual ( [ 'base' , 'base2 ' , 'comp' ] )
632
+ expect ( renderToString ( h ( Comp ) ) ) . toBe ( `1true2mixin ` )
633
+ expect ( calls ) . toEqual ( [ 'base' , 'mixin ' , 'comp' ] )
629
634
} )
630
635
631
636
test ( 'accessing setup() state from options' , async ( ) => {
0 commit comments