diff --git a/packages/firestore/__tests__/firestore.test.ts b/packages/firestore/__tests__/firestore.test.ts index 79aabda18b..d0ccee469b 100644 --- a/packages/firestore/__tests__/firestore.test.ts +++ b/packages/firestore/__tests__/firestore.test.ts @@ -1,4 +1,4 @@ -import firestore, { firebase } from '../lib'; +import firestore, { firebase, FirebaseFirestoreTypes } from '../lib'; const COLLECTION = 'firestore'; @@ -306,5 +306,27 @@ describe('Storage', function () { }, }); }); + + it('does not throw when Date is provided instead of Timestamp', async function () { + type BarType = { + myDate: FirebaseFirestoreTypes.Timestamp; + }; + + const docRef = firebase.firestore().doc(`${COLLECTION}/bar`); + await docRef.set({ + myDate: new Date(), + }); + }); + + it('does not throw when serverTimestamp is provided instead of Timestamp', async function () { + type BarType = { + myDate: FirebaseFirestoreTypes.Timestamp; + }; + + const docRef = firebase.firestore().doc(`${COLLECTION}/bar`); + await docRef.set({ + myDate: firestore.FieldValue.serverTimestamp(), + }); + }); }); });