Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom committed Dec 2, 2021
1 parent bbba616 commit a6142e2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/firestore/__tests__/firestore.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import firestore, { firebase } from '../lib';
import firestore, { firebase, FirebaseFirestoreTypes } from '../lib';

const COLLECTION = 'firestore';

Expand Down Expand Up @@ -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<BarType>(`${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<BarType>(`${COLLECTION}/bar`);
await docRef.set({
myDate: firestore.FieldValue.serverTimestamp(),
});
});
});
});

0 comments on commit a6142e2

Please sign in to comment.