@@ -88,19 +88,8 @@ describe('FirebaseListFactory', () => {
88
88
89
89
describe ( '<constructor>' , ( ) => {
90
90
91
- it ( 'should accept a Firebase db path in the constructor' , ( ) => {
92
- const list = FirebaseListFactory ( `questions` ) ;
93
- expect ( list instanceof FirebaseListObservable ) . toBe ( true ) ;
94
- } ) ;
95
-
96
91
it ( 'should accept a Firebase db ref in the constructor' , ( ) => {
97
- const list = FirebaseListFactory ( firebase . database ( ) . ref ( `questions` ) ) ;
98
- expect ( list instanceof FirebaseListObservable ) . toBe ( true ) ;
99
- } ) ;
100
-
101
- it ( 'should take an absolute url in the constructor' , ( ) => {
102
- const absoluteUrl = COMMON_CONFIG . databaseURL + '/questions' ;
103
- const list = FirebaseListFactory ( absoluteUrl ) ;
92
+ const list = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) ) ;
104
93
expect ( list instanceof FirebaseListObservable ) . toBe ( true ) ;
105
94
} ) ;
106
95
@@ -120,7 +109,7 @@ describe('FirebaseListFactory', () => {
120
109
it ( 'equalTo - should re-run a query when the observable value has emitted' , ( done : any ) => {
121
110
122
111
const subject = new Subject ( ) ;
123
- const observable = FirebaseListFactory ( questionsPath , {
112
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
124
113
query : {
125
114
orderByChild : 'height' ,
126
115
equalTo : subject
@@ -133,7 +122,7 @@ describe('FirebaseListFactory', () => {
133
122
it ( 'startAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
134
123
135
124
const subject = new Subject ( ) ;
136
- const observable = FirebaseListFactory ( questionsPath , {
125
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
137
126
query : {
138
127
orderByChild : 'height' ,
139
128
startAt : subject
@@ -146,7 +135,7 @@ describe('FirebaseListFactory', () => {
146
135
it ( 'endAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
147
136
148
137
const subject = new Subject ( ) ;
149
- const observable = FirebaseListFactory ( questionsPath , {
138
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
150
139
query : {
151
140
orderByChild : 'height' ,
152
141
endAt : subject
@@ -158,7 +147,7 @@ describe('FirebaseListFactory', () => {
158
147
159
148
it ( 'should throw an error if limitToLast and limitToFirst are chained' , ( ) => {
160
149
161
- const observable = FirebaseListFactory ( questionsPath , {
150
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
162
151
query : {
163
152
orderByChild : 'height' ,
164
153
limitToFirst : 10 ,
@@ -170,7 +159,7 @@ describe('FirebaseListFactory', () => {
170
159
171
160
it ( 'should throw an error if startAt is used with equalTo' , ( ) => {
172
161
173
- const observable = FirebaseListFactory ( questionsPath , {
162
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
174
163
query : {
175
164
orderByChild : 'height' ,
176
165
equalTo : 10 ,
@@ -182,7 +171,7 @@ describe('FirebaseListFactory', () => {
182
171
183
172
it ( 'should throw an error if endAt is used with equalTo' , ( ) => {
184
173
185
- const observable = FirebaseListFactory ( questionsPath , {
174
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
186
175
query : {
187
176
orderByChild : 'height' ,
188
177
equalTo : 10 ,
@@ -194,7 +183,7 @@ describe('FirebaseListFactory', () => {
194
183
195
184
it ( 'should throw an error if startAt and endAt is used with equalTo' , ( ) => {
196
185
197
- const observable = FirebaseListFactory ( questionsPath , {
186
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
198
187
query : {
199
188
orderByChild : 'height' ,
200
189
equalTo : 10 ,
@@ -219,7 +208,7 @@ describe('FirebaseListFactory', () => {
219
208
it ( 'equalTo - should re-run a query when the observable value has emitted' , ( done : any ) => {
220
209
221
210
const subject = new Subject ( ) ;
222
- const observable = FirebaseListFactory ( questionsPath , {
211
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
223
212
query : {
224
213
orderByValue : true ,
225
214
equalTo : subject
@@ -232,7 +221,7 @@ describe('FirebaseListFactory', () => {
232
221
it ( 'startAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
233
222
234
223
const subject = new Subject ( ) ;
235
- const observable = FirebaseListFactory ( questionsPath , {
224
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
236
225
query : {
237
226
orderByValue : true ,
238
227
startAt : subject
@@ -245,7 +234,7 @@ describe('FirebaseListFactory', () => {
245
234
it ( 'endAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
246
235
247
236
const subject = new Subject ( ) ;
248
- const observable = FirebaseListFactory ( questionsPath , {
237
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
249
238
query : {
250
239
orderByValue : true ,
251
240
endAt : subject
@@ -269,7 +258,7 @@ describe('FirebaseListFactory', () => {
269
258
it ( 'equalTo - should re-run a query when the observable value has emitted' , ( done : any ) => {
270
259
271
260
const subject = new Subject ( ) ;
272
- const observable = FirebaseListFactory ( questionsPath , {
261
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
273
262
query : {
274
263
orderByKey : true ,
275
264
equalTo : subject
@@ -282,7 +271,7 @@ describe('FirebaseListFactory', () => {
282
271
it ( 'startAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
283
272
284
273
const subject = new Subject ( ) ;
285
- const observable = FirebaseListFactory ( questionsPath , {
274
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
286
275
query : {
287
276
orderByKey : true ,
288
277
startAt : subject
@@ -295,7 +284,7 @@ describe('FirebaseListFactory', () => {
295
284
it ( 'endAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
296
285
297
286
const subject = new Subject ( ) ;
298
- const observable = FirebaseListFactory ( questionsPath , {
287
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
299
288
query : {
300
289
orderByKey : true ,
301
290
endAt : subject
@@ -318,7 +307,7 @@ describe('FirebaseListFactory', () => {
318
307
it ( 'equalTo - should re-run a query when the observable value has emitted' , ( done : any ) => {
319
308
320
309
const subject = new Subject ( ) ;
321
- const observable = FirebaseListFactory ( questionsPath , {
310
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
322
311
query : {
323
312
orderByKey : true ,
324
313
equalTo : subject
@@ -331,7 +320,7 @@ describe('FirebaseListFactory', () => {
331
320
it ( 'startAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
332
321
333
322
const subject = new Subject ( ) ;
334
- const observable = FirebaseListFactory ( questionsPath , {
323
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
335
324
query : {
336
325
orderByKey : true ,
337
326
startAt : subject
@@ -344,7 +333,7 @@ describe('FirebaseListFactory', () => {
344
333
it ( 'endAt - should re-run a query when the observable value has emitted' , ( done : any ) => {
345
334
346
335
const subject = new Subject ( ) ;
347
- const observable = FirebaseListFactory ( questionsPath , {
336
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
348
337
query : {
349
338
orderByKey : true ,
350
339
endAt : subject
@@ -360,7 +349,7 @@ describe('FirebaseListFactory', () => {
360
349
describe ( 'shape' , ( ) => {
361
350
362
351
it ( 'should have a a FirebaseListObservable shape when queried' , ( ) => {
363
- const observable = FirebaseListFactory ( questionsPath , {
352
+ const observable = FirebaseListFactory ( app . database ( ) . ref ( questionsPath ) , {
364
353
query : {
365
354
orderByChild : 'height' ,
366
355
equalTo : '1'
@@ -390,9 +379,9 @@ describe('FirebaseListFactory', () => {
390
379
val1 = { key : 'key1' } ;
391
380
val2 = { key : 'key2' } ;
392
381
val3 = { key : 'key3' } ;
393
- firebase . database ( ) . ref ( ) . remove ( done ) ;
394
- questions = FirebaseListFactory ( `questions` ) ;
395
- questionsSnapshotted = FirebaseListFactory ( `questionssnapshot` , { preserveSnapshot : true } ) ;
382
+ app . database ( ) . ref ( ) . remove ( done ) ;
383
+ questions = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) ) ;
384
+ questionsSnapshotted = FirebaseListFactory ( app . database ( ) . ref ( `questionssnapshot` ) , { preserveSnapshot : true } ) ;
396
385
ref = questions . $ref ;
397
386
refSnapshotted = questionsSnapshotted . $ref ;
398
387
} ) ;
@@ -588,7 +577,7 @@ describe('FirebaseListFactory', () => {
588
577
589
578
590
579
it ( 'should call off on all events when disposed' , ( done : any ) => {
591
- const questionRef = firebase . database ( ) . ref ( ) . child ( 'questions' ) ;
580
+ const questionRef = app . database ( ) . ref ( ) . child ( 'questions' ) ;
592
581
let firebaseSpy = spyOn ( questionRef , 'off' ) . and . callThrough ( ) ;
593
582
subscription = FirebaseListFactory ( questionRef ) . subscribe ( _ => {
594
583
expect ( firebaseSpy ) . not . toHaveBeenCalled ( ) ;
@@ -694,7 +683,7 @@ describe('FirebaseListFactory', () => {
694
683
} )
695
684
. run ( ( ) => {
696
685
// Creating a new observable so that the current zone is captured.
697
- subscription = FirebaseListFactory ( `questions` )
686
+ subscription = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) )
698
687
. filter ( d => d
699
688
. map ( v => v . $value )
700
689
. indexOf ( 'in-the-zone' ) > - 1 )
@@ -757,15 +746,15 @@ describe('FirebaseListFactory', () => {
757
746
} )
758
747
. then ( ( ) => {
759
748
760
- let query1 = FirebaseListFactory ( `questions` , {
749
+ let query1 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
761
750
query : {
762
751
orderByChild : 'data' ,
763
752
startAt : { value : 0 }
764
753
}
765
754
} ) ;
766
755
let promise1 = toPromise . call ( take . call ( query1 , 1 ) ) ;
767
756
768
- let query2 = FirebaseListFactory ( `questions` , {
757
+ let query2 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
769
758
query : {
770
759
orderByChild : 'data' ,
771
760
startAt : { value : 0 , key : 'val2' }
@@ -795,15 +784,15 @@ describe('FirebaseListFactory', () => {
795
784
} )
796
785
. then ( ( ) => {
797
786
798
- let query1 = FirebaseListFactory ( `questions` , {
787
+ let query1 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
799
788
query : {
800
789
orderByChild : 'data' ,
801
790
equalTo : { value : 0 }
802
791
}
803
792
} ) ;
804
793
let promise1 = toPromise . call ( take . call ( query1 , 1 ) ) ;
805
794
806
- let query2 = FirebaseListFactory ( `questions` , {
795
+ let query2 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
807
796
query : {
808
797
orderByChild : 'data' ,
809
798
equalTo : { value : 0 , key : 'val2' }
@@ -833,15 +822,15 @@ describe('FirebaseListFactory', () => {
833
822
} )
834
823
. then ( ( ) => {
835
824
836
- let query1 = FirebaseListFactory ( `questions` , {
825
+ let query1 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
837
826
query : {
838
827
orderByChild : 'data' ,
839
828
endAt : { value : 0 }
840
829
}
841
830
} ) ;
842
831
let promise1 = toPromise . call ( take . call ( query1 , 1 ) ) ;
843
832
844
- let query2 = FirebaseListFactory ( `questions` , {
833
+ let query2 = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
845
834
query : {
846
835
orderByChild : 'data' ,
847
836
endAt : { value : 0 , key : 'val2' }
@@ -871,7 +860,7 @@ describe('FirebaseListFactory', () => {
871
860
. then ( ( ) => {
872
861
873
862
let subject = new Subject < boolean > ( ) ;
874
- let query = FirebaseListFactory ( `questions` , {
863
+ let query = FirebaseListFactory ( app . database ( ) . ref ( `questions` ) , {
875
864
query : {
876
865
orderByChild : 'even' ,
877
866
equalTo : subject
0 commit comments