Skip to content

Commit 1d68e15

Browse files
committed
Add withFunctionTriggersDisabled overloads.
1 parent 9d5b08c commit 1d68e15

File tree

1 file changed

+24
-2
lines changed
  • packages/rules-unit-testing/src

1 file changed

+24
-2
lines changed

packages/rules-unit-testing/src/util.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,35 @@
2020
* import data into the Realtime Database or Cloud Firestore emulator without triggering locally
2121
* emulated Cloud Functions.
2222
*
23-
* This method only works with Firebase CLI version 8.13.0 or higher.
23+
* This method only works with Firebase CLI version 8.13.0 or higher. This overload works only if
24+
* the Emulator hub host:port is specified by the environment variable FIREBASE_EMULATOR_HUB.
2425
*
25-
* @param fn an function which returns a promise.
26+
* @param fn an function which may be sync or async (returns a promise)
2627
* @public
2728
*/
2829
export async function withFunctionTriggersDisabled<TResult>(
2930
fn: () => TResult | Promise<TResult>
31+
): Promise<TResult>;
32+
33+
/**
34+
* Run a setup function with background Cloud Functions triggers disabled. This can be used to
35+
* import data into the Realtime Database or Cloud Firestore emulator without triggering locally
36+
* emulated Cloud Functions.
37+
*
38+
* This method only works with Firebase CLI version 8.13.0 or higher. The Emulator hub must be
39+
* running, which host and port are specified in this overload.
40+
*
41+
* @param fn an function which may be sync or async (returns a promise)
42+
* @param hub the host and port of the Emulator Hub (ex: `{host: 'localhost', port: 4400}`)
43+
* @public
44+
*/ export async function withFunctionTriggersDisabled<TResult>(
45+
hub: { host: string; port: number },
46+
fn: () => TResult | Promise<TResult>
47+
): Promise<TResult>;
48+
49+
export async function withFunctionTriggersDisabled<TResult>(
50+
fnOrHub: { host: string; port: number } | (() => TResult | Promise<TResult>),
51+
maybeFn?: () => TResult | Promise<TResult>
3052
): Promise<TResult> {
3153
throw new Error('unimplemented');
3254
}

0 commit comments

Comments
 (0)