File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,15 @@ describe("DataSnapshot", () => {
580580 populate ( { a : [ { } ] } ) ;
581581 expect ( subject . child ( "a" ) . exists ( ) ) . to . be . false ;
582582 } ) ;
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+ } ) ;
583592 } ) ;
584593
585594 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 {
159159 */
160160 exists ( ) : boolean {
161161 const val = this . val ( ) ;
162- if ( ! val || val === null ) {
162+ if ( typeof val === "undefined" || val === null ) {
163163 return false ;
164164 }
165165 if ( typeof val === "object" && Object . keys ( val ) . length === 0 ) {
You can’t perform that action at this time.
0 commit comments