Skip to content

Commit d4ab3ba

Browse files
authored
Merge pull request soumak77#109 from bookcreator/master
Fix for soumak77#102
2 parents 01e01a9 + c20f7f9 commit d4ab3ba

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/snapshot.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ function MockDataSnapshot (ref, data, priority) {
1616

1717
MockDataSnapshot.prototype.child = function (key) {
1818
var ref = this.ref.child(key);
19-
var data = this.hasChild(key) ? this._snapshotdata[key] : null;
19+
var data = null;
20+
if (_.isObject(this._snapshotdata) && !_.isUndefined(this._snapshotdata[key])) {
21+
data = this._snapshotdata[key];
22+
}
2023
var priority = this.ref.child(key).priority;
2124
return new MockDataSnapshot(ref, data, priority);
2225
};

test/unit/snapshot.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ describe('DataSnapshot', function () {
6363
expect(child.val()).to.equal('val');
6464
});
6565

66+
it('uses child data for false values', function () {
67+
var parent = new Snapshot(ref, {key: false});
68+
var child = parent.child('key');
69+
expect(child.val()).to.equal(false);
70+
});
71+
72+
it('uses child data for 0 values', function () {
73+
var parent = new Snapshot(ref, {key: 0});
74+
var child = parent.child('key');
75+
expect(child.val()).to.equal(0);
76+
});
77+
6678
it('uses null when there is no child data', function () {
6779
var parent = new Snapshot(ref);
6880
var child = parent.child('key');

0 commit comments

Comments
 (0)