@@ -59,6 +59,30 @@ describe('VueFire', function () {
5959 } )
6060 } )
6161
62+ it ( 'bind using $bindAsArray' , function ( done ) {
63+ var vm = new Vue ( {
64+ template : '<div><div v-for="item in items">{{ item[".key"] }} {{ item.index }} </div></div>' ,
65+ created : function ( ) {
66+ this . $bindAsArray ( 'items' , firebaseRef )
67+ }
68+ } ) . $mount ( )
69+ firebaseRef . set ( {
70+ first : { index : 0 } ,
71+ second : { index : 1 } ,
72+ third : { index : 2 }
73+ } , function ( ) {
74+ expect ( vm . items ) . to . deep . equal ( [
75+ { '.key' : 'first' , index : 0 } ,
76+ { '.key' : 'second' , index : 1 } ,
77+ { '.key' : 'third' , index : 2 }
78+ ] )
79+ Vue . nextTick ( function ( ) {
80+ expect ( vm . $el . textContent ) . to . contain ( 'first 0 second 1 third 2' )
81+ done ( )
82+ } )
83+ } )
84+ } )
85+
6286 it ( 'binds array records which are primitives' , function ( done ) {
6387 var vm = new Vue ( {
6488 firebase : {
@@ -504,6 +528,28 @@ describe('VueFire', function () {
504528 } )
505529 } )
506530
531+ it ( 'binds with $bindAsObject' , function ( done ) {
532+ var obj = {
533+ first : { index : 0 } ,
534+ second : { index : 1 } ,
535+ third : { index : 2 }
536+ }
537+ var vm = new Vue ( {
538+ template : '<div>{{ items | json }}</div>' ,
539+ created : function ( ) {
540+ this . $bindAsObject ( 'items' , firebaseRef . child ( 'items' ) )
541+ }
542+ } ) . $mount ( )
543+ firebaseRef . child ( 'items' ) . set ( obj , function ( ) {
544+ obj [ '.key' ] = 'items'
545+ expect ( vm . items ) . to . deep . equal ( obj )
546+ Vue . nextTick ( function ( ) {
547+ expect ( vm . $el . textContent ) . to . contain ( JSON . stringify ( obj , null , 2 ) )
548+ done ( )
549+ } )
550+ } )
551+ } )
552+
507553 it ( 'binds to a primitive' , function ( done ) {
508554 var vm = new Vue ( {
509555 firebase : {
@@ -700,6 +746,13 @@ describe('VueFire', function () {
700746 } ) . to . throw ( / n o t b o u n d t o a F i r e b a s e r e f e r e n c e / )
701747 } )
702748
749+ it ( 'should work properly for instances with no firebase bindings' , function ( ) {
750+ expect ( function ( ) {
751+ var vm = new Vue ( )
752+ vm . $destroy ( )
753+ } ) . not . to . throw ( )
754+ } )
755+
703756 it ( 'unbinds the state bound to Firebase as an array' , function ( done ) {
704757 var vm = new Vue ( {
705758 firebase : {
0 commit comments