@@ -86,6 +86,42 @@ describe('VueFire', function () {
86
86
} )
87
87
} )
88
88
89
+ it ( 'bind using $bindAsArray after $unbind' , function ( done ) {
90
+ var refItems = firebaseRef . child ( 'items' )
91
+ var refOther = firebaseRef . child ( 'other' )
92
+ var vm = new Vue ( {
93
+ template : '<div><div v-for="item in items">{{ item[".key"] }} {{ item.index }} </div></div>' ,
94
+ created : function ( ) {
95
+ this . $bindAsArray ( 'items' , refItems )
96
+ }
97
+ } ) . $mount ( )
98
+ refItems . set ( {
99
+ first : { index : 0 } ,
100
+ second : { index : 1 } ,
101
+ third : { index : 2 }
102
+ } , function ( ) {
103
+ expect ( vm . items ) . to . deep . equal ( [
104
+ { '.key' : 'first' , index : 0 } ,
105
+ { '.key' : 'second' , index : 1 } ,
106
+ { '.key' : 'third' , index : 2 }
107
+ ] )
108
+ vm . $unbind ( 'items' )
109
+ vm . $bindAsArray ( 'items' , refOther )
110
+ refOther . set ( {
111
+ a : { index : 0 } ,
112
+ b : { index : 1 } ,
113
+ c : { index : 2 }
114
+ } , function ( ) {
115
+ expect ( vm . items ) . to . deep . equal ( [
116
+ { '.key' : 'a' , index : 0 } ,
117
+ { '.key' : 'b' , index : 1 } ,
118
+ { '.key' : 'c' , index : 2 }
119
+ ] )
120
+ done ( )
121
+ } )
122
+ } )
123
+ } )
124
+
89
125
it ( 'binds array records which are primitives' , function ( done ) {
90
126
var vm = new Vue ( {
91
127
firebase : {
@@ -531,6 +567,35 @@ describe('VueFire', function () {
531
567
} )
532
568
} )
533
569
570
+ it ( 'binds with $bindAsObject after $unbind' , function ( done ) {
571
+ var obj = {
572
+ first : { index : 0 } ,
573
+ second : { index : 1 } ,
574
+ third : { index : 2 }
575
+ }
576
+ var objOther = {
577
+ onlyOne : { index : 0 } ,
578
+ second : { index : 1 }
579
+ }
580
+ var vm = new Vue ( {
581
+ template : '<div>{{ items | json }}</div>' ,
582
+ created : function ( ) {
583
+ this . $bindAsObject ( 'items' , firebaseRef . child ( 'items' ) )
584
+ }
585
+ } ) . $mount ( )
586
+ firebaseRef . child ( 'items' ) . set ( obj , function ( ) {
587
+ obj [ '.key' ] = 'items'
588
+ expect ( vm . items ) . to . deep . equal ( obj )
589
+ vm . $unbind ( 'items' )
590
+ vm . $bindAsObject ( 'items' , firebaseRef . child ( 'others' ) )
591
+ firebaseRef . child ( 'others' ) . set ( objOther , function ( ) {
592
+ objOther [ '.key' ] = 'others'
593
+ expect ( vm . items ) . to . deep . equal ( objOther )
594
+ done ( )
595
+ } )
596
+ } )
597
+ } )
598
+
534
599
it ( 'binds with $bindAsObject' , function ( done ) {
535
600
var obj = {
536
601
first : { index : 0 } ,
0 commit comments