Skip to content

Commit e11615f

Browse files
Fix tests
1 parent ad17ecb commit e11615f

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

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

+32-29
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,23 @@ apiDescribe('Validation:', (persistence: boolean) => {
238238
describe('Collection paths', () => {
239239
validationIt(persistence, 'must be non-empty strings', db => {
240240
const baseDocRef = db.doc('foo/bar');
241-
const argumentPosition = usesFunctionalApi() ? 'second' : 'first';
242241

243-
expect(() => db.collection('')).to.throw(
244-
`Function ${
245-
usesFunctionalApi() ? 'collection' : 'Firestore.collection'
246-
}() requires its ${argumentPosition} argument to be of type ` +
247-
'non-empty string, but it was: ""'
248-
);
249-
expect(() => baseDocRef.collection('')).to.throw(
250-
`Function ${
251-
usesFunctionalApi() ? 'collection' : 'DocumentReference.collection'
252-
}() requires its ${argumentPosition} argument to be of type ` +
253-
'non-empty string, but it was: ""'
254-
);
255-
256-
if (validatesJsInput) {
242+
if (usesFunctionalApi()) {
243+
expect(() => db.collection('')).to.throw(
244+
'Function collection() cannot be called with an empty path.'
245+
);
246+
expect(() => baseDocRef.collection('')).to.throw(
247+
'Function DocumentReference.collection() cannot be called with an empty path.'
248+
);
249+
} else {
250+
expect(() => db.collection('')).to.throw(
251+
'Function Firestore.collection() requires its first ' +
252+
'argument to be of type non-empty string, but it was: ""'
253+
);
254+
expect(() => baseDocRef.collection('')).to.throw(
255+
'Function DocumentReference.collection() requires its first ' +
256+
'argument to be of type non-empty string, but it was: ""'
257+
);
257258
expect(() => db.collection(null as any)).to.throw(
258259
'Function Firestore.collection() requires its first argument ' +
259260
'to be of type non-empty string, but it was: null'
@@ -309,21 +310,23 @@ apiDescribe('Validation:', (persistence: boolean) => {
309310
describe('Document paths', () => {
310311
validationIt(persistence, 'must be strings', db => {
311312
const baseCollectionRef = db.collection('foo');
312-
const argumentPosition = usesFunctionalApi() ? 'second' : 'first';
313313

314-
expect(() => db.doc('')).to.throw(
315-
`Function ${usesFunctionalApi() ? 'doc' : 'Firestore.doc'}() ` +
316-
`requires its ${argumentPosition} argument to be of type non-empty ` +
317-
'string, but it was: ""'
318-
);
319-
expect(() => baseCollectionRef.doc('')).to.throw(
320-
`Function ${
321-
usesFunctionalApi() ? 'doc' : 'CollectionReference.doc'
322-
}() requires its ${argumentPosition} argument to be of type ` +
323-
'non-empty string, but it was: ""'
324-
);
325-
326-
if (validatesJsInput) {
314+
if (usesFunctionalApi()) {
315+
expect(() => db.doc('')).to.throw(
316+
'Function doc() cannot be called with an empty path.'
317+
);
318+
expect(() => baseCollectionRef.doc('')).to.throw(
319+
'Function CollectionReference.doc() cannot be called with an empty path.'
320+
);
321+
} else {
322+
expect(() => db.doc('')).to.throw(
323+
'Function Firestore.doc() requires its first ' +
324+
'argument to be of type non-empty string, but it was: ""'
325+
);
326+
expect(() => baseCollectionRef.doc('')).to.throw(
327+
'Function CollectionReference.doc() requires its first ' +
328+
'argument to be of type non-empty string, but it was: ""'
329+
);
327330
expect(() => db.doc(null as any)).to.throw(
328331
'Function Firestore.doc() requires its first argument to be ' +
329332
'of type non-empty string, but it was: null'

0 commit comments

Comments
 (0)