firebase - functions.database.DeltaSnapshot#changed unexpected result -
i using changed() function in functions , result not expected given documentation.
i added few tests following file illustrate issue. https://github.com/firebase/firebase-functions/blob/master/src/providers/database.ts
it('should false when current value has not changed', () => { populate({ a: { b: 'c' } }, { a: { b: 'c' } }); expect(subject.child('a').changed()).to.be.false; }); it('should false when current value has not changed, child path exists', () => { populate({ a: { b: 'c' } }, { a: { b: 'c' } }); expect(subject.child('a/b').changed()).to.be.false; }); it('should false when current value has not changed, child path not exist', () => { populate({ a: { b: 'c' } }, { a: { b: 'c' } }); expect(subject.child('a/d').changed()).to.be.false; }); the first 2 tests fail, expected changed() function return false. misunderstand documentation?
refs https://firebase.google.com/docs/reference/functions/functions.database.deltasnapshot#changed
in unit tests of firebase sdk cloud functions, signature of populate populate(data, delta). is, original data , change original data.
when sdk checks changes, seeing if value present in delta payload. in deployed function, hasn't changed explicitly not sent in delta payload.
Comments
Post a Comment