Skip to content

Commit 241af33

Browse files
authored
Merge pull request soumak77#85 from adrianosmond/patch-1
Support ref.push() without arguments
2 parents 75631cb + f45f6e3 commit 241af33

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/firebase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ MockFirebase.prototype.push = function (data, callback) {
240240
validate.data(data);
241241
return utils.createThenableReference(child, child.set(data, callback));
242242
} else {
243-
return utils.createThenableReference(child, Promise.resolve(null));
243+
return utils.createThenableReference(child, Promise.resolve(child));
244244
}
245245
};
246246

test/unit/firebase.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,14 @@ describe('MockFirebase', function () {
886886
}, done);
887887
ref.flush();
888888
});
889+
890+
it('should return thenable reference when no arguments are passed', function (done) {
891+
var thenable = ref.push();
892+
thenable.then(function(child) {
893+
expect(child.parent).to.eql(ref);
894+
done();
895+
}, done);
896+
});
889897

890898
it('can add data by auto id', function () {
891899
var id = ref._newAutoId();

0 commit comments

Comments
 (0)