File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -32,4 +32,25 @@ describe('providers/database', () => {
32
32
expect ( snapshot . val ( ) ) . to . deep . equal ( null ) ;
33
33
expect ( snapshot . ref . key ) . to . equal ( 'path' ) ;
34
34
} ) ;
35
+
36
+ it ( 'should use the default test apps databaseURL if no instance is specified in makeDataSnapshot' , async ( ) => {
37
+ const snapshot = makeDataSnapshot ( null , 'path' , null ) ;
38
+
39
+ expect ( snapshot . ref . toString ( ) ) . to . equal (
40
+ 'https://not-a-project.firebaseio.com/path'
41
+ ) ;
42
+ } ) ;
43
+
44
+ it ( 'should allow different DB instance to be specified in makeDataSnapshot' , async ( ) => {
45
+ const snapshot = makeDataSnapshot (
46
+ null ,
47
+ 'path' ,
48
+ null ,
49
+ 'https://another-instance.firebaseio.com'
50
+ ) ;
51
+
52
+ expect ( snapshot . ref . toString ( ) ) . to . equal (
53
+ 'https://another-instance.firebaseio.com/path'
54
+ ) ;
55
+ } ) ;
35
56
} ) ;
Original file line number Diff line number Diff line change @@ -36,12 +36,18 @@ export function makeDataSnapshot(
36
36
* You do not need to supply this parameter if you supplied Firebase config values when initializing
37
37
* firebase-functions-test.
38
38
*/
39
- firebaseApp ?: app . App
39
+ firebaseApp ?: app . App ,
40
+ /**
41
+ * The RTDB instance to use when creating snapshot. This will override the `firebaseApp` parameter.
42
+ * If omitted the default RTDB instance is used.
43
+ */
44
+ instance ?: string
40
45
) : database . DataSnapshot {
41
46
return new database . DataSnapshot (
42
47
val ,
43
48
refPath ,
44
- firebaseApp || testApp ( ) . getApp ( )
49
+ firebaseApp || testApp ( ) . getApp ( ) ,
50
+ instance
45
51
) ;
46
52
}
47
53
You can’t perform that action at this time.
0 commit comments