export class FirebaseMock { log = [ ] ; data = { } ; mockDb ( ) { return new FireBaseDbMock ( this ) ; } } export class FireBaseDbMock { constructor ( private fbMock ) { } ref ( ref ) { return new FirebaseDbRefMock ( this . fbMock , ref ) ; } } export class FirebaseDbRefMock { constructor ( private fbMock , private ref ) { } set ( data ) { this . fbMock . data [ this . ref ] = data ; return Promise . resolve ( new FirebaseDataSnapshotMock ( this . fbMock , data ) ) ; } once ( eventType ) { return Promise . resolve ( new FirebaseDataSnapshotMock ( this . fbMock , this . fbMock . data [ this . ref ] ) ) ; } } export class FirebaseDataSnapshotMock { constructor ( private fbMock , private data ) { } val ( ) { return this . data || null ; } }