Skip to content

Commit 4a49493

Browse files
committed
Guard validation tests with USE_EMULATOR
1 parent 8d0a11d commit 4a49493

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

packages/firestore/test/integration/api/validation.test.ts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ import {
6464
import {
6565
ALT_PROJECT_ID,
6666
DEFAULT_PROJECT_ID,
67-
TARGET_DB_ID
67+
TARGET_DB_ID,
68+
USE_EMULATOR
6869
} from '../util/settings';
6970

7071
// We're using 'as any' to pass invalid values to APIs for testing purposes.
@@ -177,6 +178,18 @@ apiDescribe('Validation:', persistence => {
177178
}
178179
);
179180

181+
validationIt(
182+
persistence,
183+
'connectFirestoreEmulator() can set mockUserToken object',
184+
() => {
185+
const db = newTestFirestore(newTestApp('test-project'));
186+
// Verify that this doesn't throw.
187+
connectFirestoreEmulator(db, '127.0.0.1', 9000, {
188+
mockUserToken: { sub: 'foo' }
189+
});
190+
}
191+
);
192+
180193
validationIt(
181194
persistence,
182195
'disallows calling connectFirestoreEmulator() for first time after use',
@@ -195,37 +208,29 @@ apiDescribe('Validation:', persistence => {
195208
persistence,
196209
'allows calling connectFirestoreEmulator() after use with same config',
197210
async db => {
198-
connectFirestoreEmulator(db, '127.0.0.1', 9000);
199-
await setDoc(doc(db, 'foo/bar'), {});
200-
expect(() =>
201-
connectFirestoreEmulator(db, '127.0.0.1', 9000)
202-
).to.not.throw();
211+
if (USE_EMULATOR) {
212+
connectFirestoreEmulator(db, '127.0.0.1', 9000);
213+
await setDoc(doc(db, 'foo/bar'), {});
214+
expect(() =>
215+
connectFirestoreEmulator(db, '127.0.0.1', 9000)
216+
).to.not.throw();
217+
}
203218
}
204219
);
205220

206221
validationIt(
207222
persistence,
208223
'disallows calling connectFirestoreEmulator() after use with different config',
209224
async db => {
210-
const errorMsg =
211-
'Firestore has already been started and its settings can no longer be changed.';
212-
connectFirestoreEmulator(db, '127.0.0.1', 9000);
213-
await setDoc(doc(db, 'foo/bar'), {});
214-
expect(() => connectFirestoreEmulator(db, '127.0.0.1', 9001)).to.throw(
215-
errorMsg
216-
);
217-
}
218-
);
219-
220-
validationIt(
221-
persistence,
222-
'connectFirestoreEmulator() can set mockUserToken object',
223-
() => {
224-
const db = newTestFirestore(newTestApp('test-project'));
225-
// Verify that this doesn't throw.
226-
connectFirestoreEmulator(db, '127.0.0.1', 9000, {
227-
mockUserToken: { sub: 'foo' }
228-
});
225+
if (USE_EMULATOR) {
226+
const errorMsg =
227+
'Firestore has already been started and its settings can no longer be changed.';
228+
connectFirestoreEmulator(db, '127.0.0.1', 9000);
229+
await setDoc(doc(db, 'foo/bar'), {});
230+
expect(() =>
231+
connectFirestoreEmulator(db, '127.0.0.1', 9001)
232+
).to.throw(errorMsg);
233+
}
229234
}
230235
);
231236

0 commit comments

Comments
 (0)