Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions spec/v1/providers/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,15 @@ describe("DataSnapshot", () => {
populate({ a: [{}] });
expect(subject.child("a").exists()).to.be.false;
});

it("should be true for a falsy value (other than null)", () => {
populate({ num: 0, bool: false, n: null });
expect(subject.exists()).to.be.true;
expect(subject.child("num").exists()).to.be.true;
expect(subject.child("bool").exists()).to.be.true;
expect(subject.child("n").exists()).to.be.false;
expect(subject.child("missing").exists()).to.be.false;
});
});

describe("#forEach(action: (a: DataSnapshot) => boolean): boolean", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/providers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class DataSnapshot implements database.DataSnapshot {
*/
exists(): boolean {
const val = this.val();
if (!val || val === null) {
if (typeof val === "undefined" || val === null) {
return false;
}
if (typeof val === "object" && Object.keys(val).length === 0) {
Expand Down