import * as mongodb from "mongodb" ; import { MockCollection } from "./mockCollection" ; import { EventEmitter } from "events" ; import { MongoCallback } from "mongodb" ; import { ProfilingLevel } from "mongodb" ; import { ClientSession } from "mongodb" ; export class MockDb extends EventEmitter implements mongodb . Db { serverConfig : mongodb . Server | mongodb . ReplSet | mongodb . Mongos ; bufferMaxEntries : number ; databaseName : string ; options : any ; native_parser : boolean ; slaveOk : boolean ; writeConcern : any ; cachedCollections : Map < string , MockCollection > = new Map ( ) ; constructor ( name = "test" ) { super ( ) ; this . databaseName = name ; } addUser ( username , password , callback ) ; addUser ( username , password , options ? ) ; addUser ( username , password , options , callback ) ; addUser ( username , password , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } admin ( ) { throw new Error ( "Method not implemented." ) ; } collection < TSchema = any > ( name ) ; collection < TSchema = any > ( name , callback ) ; collection < TSchema = any > ( name , options , callback ) ; collection ( collectionName , optionsOrCallback ? , callback ? ) { if ( callback === undefined ) { callback = optionsOrCallback ; } var collection = this . cachedCollections . get ( collectionName ) ; if ( ! collection ) { collection = new MockCollection ( [ ] , collectionName ) ; this . cachedCollections . set ( collectionName , collection ) ; if ( callback ) { process . nextTick ( ( ) => callback ( null , collection ) ) ; } } return collection ; } collections ( ) ; collections ( callback ) ; collections ( callback ? ) { throw new Error ( "Method not implemented." ) ; } command ( command , callback ) ; command ( command , options ? ) ; command ( command , options , callback ) ; command ( command , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } createCollection < TSchema = any > ( name , callback ) ; createCollection < TSchema = any > ( name , options ? ) ; createCollection < TSchema = any > ( name , options , callback ) ; createCollection ( name , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } createIndex ( name , fieldOrSpec , callback ) ; createIndex ( name , fieldOrSpec , options ? ) ; createIndex ( name , fieldOrSpec , options , callback ) ; createIndex ( name , fieldOrSpec , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } dropCollection ( name ) ; dropCollection ( name , callback ) ; dropCollection ( name , callback ? ) { throw new Error ( "Method not implemented." ) ; } dropDatabase ( ) ; dropDatabase ( callback ) ; dropDatabase ( callback ? ) { throw new Error ( "Method not implemented." ) ; } executeDbAdminCommand ( command , callback ) ; executeDbAdminCommand ( command , options ? ) ; executeDbAdminCommand ( command , options , callback ) ; executeDbAdminCommand ( command , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } indexInformation ( name , callback ) ; indexInformation ( name , options ? ) ; indexInformation ( name , options , callback ) ; indexInformation ( name , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } listCollections ( filter ? , options ? ) { throw new Error ( "Method not implemented." ) ; } profilingInfo ( callback ) ; profilingInfo ( options ? ) ; profilingInfo ( options , callback ) ; profilingInfo ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } profilingLevel ( callback ) ; profilingLevel ( options ? ) ; profilingLevel ( options , callback ) ; profilingLevel ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } removeUser ( username , callback ) ; removeUser ( username , options ? ) ; removeUser ( username , options , callback ) ; removeUser ( username , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } renameCollection < TSchema = any > ( fromCollection , toCollection , callback ) ; renameCollection < TSchema = any > ( fromCollection , toCollection , options ? ) ; renameCollection < TSchema = any > ( fromCollection , toCollection , options , callback ) ; renameCollection ( fromCollection , toCollection , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } stats ( callback ) ; stats ( options ? ) ; stats ( options , callback ) ; stats ( options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } setProfilingLevel ( level , callback ) ; setProfilingLevel ( level , options ? ) ; setProfilingLevel ( level , options , callback ) ; setProfilingLevel ( level ? , options ? , callback ? ) { throw new Error ( "Method not implemented." ) ; } }