@@ -39,6 +39,91 @@ describe('VueFire', function () {
39
39
} )
40
40
} )
41
41
42
+ describe ( 'on ready callback' , function ( ) {
43
+ it ( 'arrays' , function ( done ) {
44
+ firebaseRef . set ( {
45
+ first : { index : 0 } ,
46
+ second : { index : 1 } ,
47
+ third : { index : 2 }
48
+ } , function ( ) {
49
+ new Vue ( {
50
+ firebase : {
51
+ items : {
52
+ source : firebaseRef ,
53
+ readyCallback : function ( ) {
54
+ expect ( this . items ) . to . deep . equal ( [
55
+ { '.key' : 'first' , index : 0 } ,
56
+ { '.key' : 'second' , index : 1 } ,
57
+ { '.key' : 'third' , index : 2 }
58
+ ] )
59
+ done ( )
60
+ }
61
+ }
62
+ }
63
+ } ) . $mount ( )
64
+ } )
65
+ } )
66
+
67
+ it ( 'objects' , function ( done ) {
68
+ firebaseRef . child ( 'first' ) . set ( {
69
+ index : 0
70
+ } , function ( ) {
71
+ new Vue ( {
72
+ firebase : {
73
+ item : {
74
+ source : firebaseRef . child ( 'first' ) ,
75
+ asObject : true ,
76
+ readyCallback : function ( ) {
77
+ expect ( this . item ) . to . deep . equal (
78
+ { '.key' : 'first' , index : 0 }
79
+ )
80
+ done ( )
81
+ }
82
+ }
83
+ }
84
+ } ) . $mount ( )
85
+ } )
86
+ } )
87
+
88
+ it ( '$bindAsArray' , function ( done ) {
89
+ firebaseRef . set ( {
90
+ first : { index : 0 } ,
91
+ second : { index : 1 } ,
92
+ third : { index : 2 }
93
+ } , function ( ) {
94
+ new Vue ( {
95
+ created : function ( ) {
96
+ this . $bindAsArray ( 'items' , firebaseRef , null , function ( ) {
97
+ expect ( this . items ) . to . deep . equal ( [
98
+ { '.key' : 'first' , index : 0 } ,
99
+ { '.key' : 'second' , index : 1 } ,
100
+ { '.key' : 'third' , index : 2 }
101
+ ] )
102
+ done ( )
103
+ } )
104
+ }
105
+ } ) . $mount ( )
106
+ } )
107
+ } )
108
+
109
+ it ( '$bindAsObject' , function ( done ) {
110
+ firebaseRef . child ( 'first' ) . set ( {
111
+ index : 0
112
+ } , function ( ) {
113
+ new Vue ( {
114
+ created : function ( ) {
115
+ this . $bindAsObject ( 'item' , firebaseRef . child ( 'first' ) , null , function ( ) {
116
+ expect ( this . item ) . to . deep . equal (
117
+ { '.key' : 'first' , index : 0 }
118
+ )
119
+ done ( )
120
+ } )
121
+ }
122
+ } ) . $mount ( )
123
+ } )
124
+ } )
125
+ } )
126
+
42
127
describe ( 'bind as Array' , function ( ) {
43
128
it ( 'throws error for invalid firebase ref' , function ( ) {
44
129
helpers . invalidFirebaseRefs . forEach ( function ( ref ) {
0 commit comments