Skip to content

Commit

Permalink
fix: broken e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Dec 18, 2024
1 parent 61e782c commit e3064a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/firestore/e2e/WriteBatch/commit.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,17 @@ describe('firestore.WriteBatch.commit()', function () {
});

it('should set & commit', async function () {
const { getFirestore, writeBatch, doc, setDoc, getDoc, deleteDoc } = firestoreModular;
const { getFirestore, writeBatch, doc, getDoc, deleteDoc } = firestoreModular;
const db = getFirestore();
const lRef = doc(db, `${COLLECTION}/LON`);
const nycRef = doc(db, `${COLLECTION}/NYC`);
const sfRef = doc(db, `${COLLECTION}/SF`);

const batch = writeBatch(db);

setDoc(batch, lRef, { name: 'London' });
setDoc(batch, nycRef, { name: 'New York' });
setDoc(batch, sfRef, { name: 'San Francisco' });
// This is the correct way of setting batch for modular API
batch.set(lRef, { name: 'London' });
batch.set(nycRef, { name: 'New York' });
batch.set(sfRef, { name: 'San Francisco' });

await batch.commit();

Expand Down
6 changes: 4 additions & 2 deletions packages/firestore/lib/FirestoreDocumentReference.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
isString,
isUndefined,
createDeprecationProxy,
filterModularArgument,
} from '@react-native-firebase/app/lib/common';
import NativeError from '@react-native-firebase/app/lib/internal/NativeFirebaseError';
import { parseSetOptions, parseSnapshotArgs, parseUpdateArgs } from './utils';
Expand Down Expand Up @@ -197,15 +198,16 @@ export default class FirestoreDocumentReference {
}

update(...args) {
if (args.length === 0) {
const updatedArgs = filterModularArgument(args);
if (updatedArgs.length === 0) {
throw new Error(
'firebase.firestore().doc().update(*) expected at least 1 argument but was called with 0 arguments.',
);
}

let data;
try {
data = parseUpdateArgs(args);
data = parseUpdateArgs(updatedArgs);
} catch (e) {
throw new Error(`firebase.firestore().doc().update(*) ${e.message}`);
}
Expand Down

0 comments on commit e3064a3

Please sign in to comment.