Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 0569ebd

Browse files
committed
makeNodeResolver should check error === null instead of falsy
1 parent afc3fe7 commit 0569ebd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@
229229

230230
makeNodeResolver:function(deferred){
231231
return function(err,result){
232-
if(err){
233-
deferred.reject(err);
232+
if(err === null){
233+
deferred.resolve(result);
234234
}
235235
else {
236-
deferred.resolve(result);
236+
deferred.reject(err);
237237
}
238-
}
238+
};
239239
},
240240

241241
wait: function(fn, wait) {

tests/unit/utils.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ describe('$firebaseUtils', function () {
198198
expect(deferred.reject).toHaveBeenCalledWith(error);
199199
});
200200

201+
it('should reject the promise if the first argument is not null', function(){
202+
callback(false);
203+
expect(deferred.reject).toHaveBeenCalledWith(false);
204+
});
205+
201206
it('should resolve the promise if the first argument is falsy', function(){
202207
var result = {data:'hello world'};
203208
callback(null,result);

0 commit comments

Comments
 (0)