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', () => {
3232 expect ( snapshot . val ( ) ) . to . deep . equal ( null ) ;
3333 expect ( snapshot . ref . key ) . to . equal ( 'path' ) ;
3434 } ) ;
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+ } ) ;
3556} ) ;
Original file line number Diff line number Diff line change @@ -36,12 +36,18 @@ export function makeDataSnapshot(
3636 * You do not need to supply this parameter if you supplied Firebase config values when initializing
3737 * firebase-functions-test.
3838 */
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
4045) : database . DataSnapshot {
4146 return new database . DataSnapshot (
4247 val ,
4348 refPath ,
44- firebaseApp || testApp ( ) . getApp ( )
49+ firebaseApp || testApp ( ) . getApp ( ) ,
50+ instance
4551 ) ;
4652}
4753
You can’t perform that action at this time.
0 commit comments