Skip to content

Commit 10b999f

Browse files
committed
fix(firestore): adjust withConverter test settings
1 parent 04d563a commit 10b999f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/firestore/e2e/withConverter.e2e.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ const {
3030
getDocs,
3131
writeBatch,
3232
increment,
33+
initializeFirestore,
3334
} = firestoreModular;
35+
const { getApp } = modular;
36+
3437

3538
// Used for testing the FirestoreDataConverter.
3639
class Post {
@@ -84,6 +87,16 @@ function withTestDb(fn) {
8487
return fn(getFirestore());
8588
}
8689

90+
async function withModifiedUndefinedPropertiesTestDb(fn) {
91+
const db = await initializeFirestore(getApp(), {
92+
ignoreUndefinedProperties: false,
93+
});
94+
await fn(db);
95+
await initializeFirestore(getApp(), {
96+
ignoreUndefinedProperties: true,
97+
});
98+
}
99+
87100
function withTestCollection(fn) {
88101
return withTestDb(db => fn(collection(db, COLLECTION)));
89102
}
@@ -276,7 +289,7 @@ describe('firestore.Transaction', function () {
276289

277290
it('requires the correct converter for Partial usage', async function () {
278291
const db = firebase.firestore();
279-
db._settings.ignoreUndefinedProperties = false;
292+
db.settings({ ignoreUndefinedProperties: false });
280293
const coll = db.collection('posts');
281294
const ref = coll.doc('post').withConverter(postConverter);
282295
const batch = db.batch();
@@ -287,7 +300,7 @@ describe('firestore.Transaction', function () {
287300
} catch (error) {
288301
error.message.should.containEql('Unsupported field value: undefined');
289302
}
290-
db._settings.ignoreUndefinedProperties = true;
303+
db.settings({ ignoreUndefinedProperties: true });
291304
return Promise.resolve();
292305
});
293306

@@ -519,8 +532,7 @@ describe('firestore.Transaction', function () {
519532
});
520533

521534
it('requires the correct converter for Partial usage', async function () {
522-
return withTestDb(async db => {
523-
db._settings.ignoreUndefinedProperties = false;
535+
return withModifiedUndefinedPropertiesTestDb(async db => {
524536
const coll = collection(db, 'posts');
525537
const ref = doc(coll, 'post').withConverter(postConverter);
526538
const batch = writeBatch(db);
@@ -531,7 +543,6 @@ describe('firestore.Transaction', function () {
531543
} catch (error) {
532544
error.message.should.containEql('Unsupported field value: undefined');
533545
}
534-
db._settings.ignoreUndefinedProperties = true;
535546
return Promise.resolve();
536547
});
537548
});

0 commit comments

Comments
 (0)