firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Firestore context params bind #75

Open Tomer781 opened 3 years ago

Tomer781 commented 3 years ago

While using the library to emulate a firestore document event, I noticed that I have to send the params separately. This is a suggestion to bind the params from the DocumentSnapshot refPath property.

enable this usage:


const snap = test.firestore.makeDocumentSnapshot({}, 'wildcard/111/anotherwildcard/111');
      const wrapped = test.wrap(myFunctions.matchApartmentToUsers);
      return wrapped(snap).then(() => {});

instead of:

const snap = test.firestore.makeDocumentSnapshot({}, 'wildcard/111/anotherwildcard/111');
      const wrapped = test.wrap(myFunctions.matchApartmentToUsers);
      return wrapped(snap, {params:{wildcard:"111",anotherwildcard:"111"}}).then(() => {});