File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,15 @@ describe("DataSnapshot", () => {
580
580
populate ( { a : [ { } ] } ) ;
581
581
expect ( subject . child ( "a" ) . exists ( ) ) . to . be . false ;
582
582
} ) ;
583
+
584
+ it ( "should be true for a falsy value (other than null)" , ( ) => {
585
+ populate ( { num : 0 , bool : false , n : null } ) ;
586
+ expect ( subject . exists ( ) ) . to . be . true ;
587
+ expect ( subject . child ( "num" ) . exists ( ) ) . to . be . true ;
588
+ expect ( subject . child ( "bool" ) . exists ( ) ) . to . be . true ;
589
+ expect ( subject . child ( "n" ) . exists ( ) ) . to . be . false ;
590
+ expect ( subject . child ( "missing" ) . exists ( ) ) . to . be . false ;
591
+ } ) ;
583
592
} ) ;
584
593
585
594
describe ( "#forEach(action: (a: DataSnapshot) => boolean): boolean" , ( ) => {
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ export class DataSnapshot implements database.DataSnapshot {
159
159
*/
160
160
exists ( ) : boolean {
161
161
const val = this . val ( ) ;
162
- if ( ! val || val === null ) {
162
+ if ( typeof val === "undefined" || val === null ) {
163
163
return false ;
164
164
}
165
165
if ( typeof val === "object" && Object . keys ( val ) . length === 0 ) {
You can’t perform that action at this time.
0 commit comments