<commit_before>import * as mongoose from 'mongoose';

// dummy variables
var cb = function () {};

/*
 * Most of these tests are taken directly from the examples
 * in the Mongoose API documentation.
 *
 * http://mongoosejs.com/docs/guide.html
 * http://mongoosejs.com/docs/api.html
 */

/*
 * section index.js
 * http://mongoosejs.com/docs/api.html#index-js
 */
var connectUri = 'mongodb://user:pass@localhost:port/database';
const connection1: Promise<mongoose.Mongoose> = mongoose.connect(connectUri);
const connection2: Promise<mongoose.Mongoose> = mongoose.connect(connectUri, {
  user: 'larry',
  pass: '<PASSWORD>',
  config: {
    autoIndex: true,
  },
  mongos: true,
  bufferCommands: false,
  useNewUrlParser: true,
  useFindAndModify: true,
  useUnifiedTopology: true,
  useCreateIndex: true,
  autoIndex: true,
  autoCreate: true,
});
const connection3 = mongoose.connect(connectUri, function (error) {
  error.stack;
});

var mongooseConnection: mongoose.Connection = mongoose.createConnection();
mongooseConnection.dropDatabase().then(()=>{});
mongooseConnection.dropCollection('foo').then(()=>{});
mongoose.createConnection(connectUri).then((conn)=> {
  return conn.collections;
}, () => {

var connections: mongoose.Connection[] = mongoose.connections;

});
mongoose.createConnection(connectUri).openUri('');
mongoose.createConnection(connectUri, {
  db: {
    native_parser: true
  }
}).openUri('');
const dcWithCallback: void = mongoose.disconnect(cb);
const dcPromise: Promise<void> = mongoose.disconnect();
mongoose.get('test');
mongoose.model('Actor', new mongoose.Schema({
  name: String
}), 'collectionName', true).find({});
mongoose.model('Actor').find({});
mongoose.modelNames()[0].toLowerCase();
mongoose.models.Actor.findOne({}).exec();
new (new mongoose.Mongoose(9, 8, 7)).Mongoose(1, 2, 3).connect('');
mongoose.plugin(cb, {}).connect('');
mongoose.set('test', 'value');
mongoose.set('debug', function(collectionName: any, methodName: any, arg1: any, arg2: any) {});
mongoose.STATES.hasOwnProperty('');
mongoose.STATES.disconnected === 0;
mongoose.STATES.connected === 1;

mongoose.connection.on('error', cb);
new mongoose.mongo.MongoError('error').stack;
mongoose.SchemaTypes.String;
mongoose.SchemaTypes.ObjectId;
mongoose.SchemaTypes.Decimal128;
mongoose.SchemaTypes.Map;
mongoose.Types.ObjectId;
mongoose.Types.Decimal128;
mongoose.version.toLowerCase();

const sslConnections: {[key: string]: mongoose.Connection} = {
  basic: mongoose.createConnection(connectUri, {ssl: true}),
  customCA: mongoose.createConnection(
    connectUri,
    {
      ssl: true,
      sslCA: [new Buffer('ca string')],
      sslCRL: [new Buffer('crl buffer')],
      sslCert: 'ssl cert',
      sslKey: new Buffer('ssl private key'),
      sslPass: '<PASSWORD>',
      servername: 'localhost',
      checkServerIdentity: true,
      ciphers: 'ciphers',
      ecdhCurve: 'ecdhCurve',
    }
  ),
};

/*
 * section collection.js
 * http://mongoosejs.com/docs/api.html#collection-js
 *
 * section drivers/node-mongodb-native/collection.js
 * http://mongoosejs.com/docs/api.html#drivers-node-mongodb-native-collection-js
 */
var coll1 = <mongoose.Collection> {};
coll1.$format(999).toLowerCase();
coll1.$print('name', 'i', [1, 2, 3]);
coll1.getIndexes();
/* inherited properties */
coll1.collectionName;
coll1.conn;
coll1.name;
coll1.ensureIndex();
coll1.find({});
coll1.insert({}, {});

var coll2 = new mongoose.Collection('', new mongoose.Connection(mongoose));
coll2.$format(999).toLowerCase();
/* inherited properties */
coll2.initializeOrderedBulkOp;
coll2.indexExists;

/*
 * section connection.js
 * http://mongoosejs.com/docs/api.html#connection-js
 *
 * section section drivers/node-mongodb-native/connection.js
 * http://mongoosejs.com/docs/api.html#drivers-node-mongodb-native-connection-js
 */
var conn1: mongoose.Connection = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
conn1 = new mongoose.Connection(mongoose);
conn1.close().then(function () {}).catch(function (err) {});
conn1.close(true).then(function () {}).catch(function (err) {});
conn1.close(function (err) {});
conn1.close(true, function (err) {});
conn1.collection('name').$format(999);
conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
conn1.deleteModel('myModel');
conn1.models.myModel.findOne().exec();
interface IStatics {
  staticMethod1: (a: number) => string;
}
conn1.modelNames()[0].toLowerCase();
conn1.config.hasOwnProperty('');
conn1.db.bufferMaxEntries;
conn1.collections['coll'].$format(999);
conn1.readyState.toFixed();
conn1.name.toLowerCase()
conn1.host.toLowerCase()
conn1.port.toFixed()
conn1.useDb('myDb').useDb('');
mongoose.Connection.STATES.hasOwnProperty('');
mongoose.Connection.STATES.disconnected === 0;
mongoose.Connection.STATES.connected === 1;

/* inherited properties */
conn1.on('data', cb);
conn1.addListener('close', cb);

// The connection returned by useDb is *not* thenable.
// From https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26057#issuecomment-396150819
const getDB = async (tenant: string)=> {
  return conn1.useDb(tenant);
};

/*
 * section error.js
 * http://mongoosejs.com/docs/api.html#error-js
 */
var mongooseError: mongoose.Error = new mongoose.Error('error');
mongooseError.name;
/* inherited properties */
mongooseError.message;
mongooseError.stack;
/* static properties */
mongoose.Error.messages.hasOwnProperty('');
mongoose.Error.Messages.hasOwnProperty('');

/*
 * section error/cast.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.CastError
 */
var castError: mongoose.Error.CastError = new mongoose.Error.CastError('', '', '');
castError.name;
castError.stringValue;
castError.kind;
castError.path;
castError.value;
castError.setModel('foo');
/* inherited properties */
castError.message;
castError.stack;

/*
 * section error/validator.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.ValidatorError
 */
var validatorError: mongoose.Error.ValidatorError = new mongoose.Error.ValidatorError({ message: 'bar' })
validatorError.name;
validatorError.properties;
validatorError.kind;
validatorError.path;
validatorError.value;
validatorError.toString().toLowerCase();
validatorError.formatMessage('foo', {});
validatorError.formatMessage('foo', (bar: any)=>{ return bar; });
/* inherited properties */
validatorError.message;
validatorError.stack;

/*
 * section error/validation.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.ValidationError
 */
var doc = <mongoose.Document>{};
var validationError: mongoose.Error.ValidationError = new mongoose.Error.ValidationError(doc);
validationError.name;
validationError.toString().toLowerCase();
validationError.inspect();
validationError.toJSON().hasOwnProperty('');<commit_msg>Fix a type in mongoose tests (#42189)<commit_after>import * as mongoose from 'mongoose';

// dummy variables
var cb = function () {};

/*
 * Most of these tests are taken directly from the examples
 * in the Mongoose API documentation.
 *
 * http://mongoosejs.com/docs/guide.html
 * http://mongoosejs.com/docs/api.html
 */

/*
 * section index.js
 * http://mongoosejs.com/docs/api.html#index-js
 */
var connectUri = 'mongodb://user:pass@localhost:port/database';
const connection1: Promise<mongoose.Mongoose> = mongoose.connect(connectUri);
const connection2: Promise<mongoose.Mongoose> = mongoose.connect(connectUri, {
  user: 'larry',
  pass: '<PASSWORD>',
  config: {
    autoIndex: true,
  },
  mongos: true,
  bufferCommands: false,
  useNewUrlParser: true,
  useFindAndModify: true,
  useUnifiedTopology: true,
  useCreateIndex: true,
  autoIndex: true,
  autoCreate: true,
});
const connection3 = mongoose.connect(connectUri, function (error) {
  error.stack;
});

var mongooseConnection: mongoose.Connection = mongoose.createConnection();
mongooseConnection.dropDatabase().then(()=>{});
mongooseConnection.dropCollection('foo').then(()=>{});
mongoose.createConnection(connectUri).then((conn)=> {
  return conn.collections;
}, () => {

var connections: mongoose.Connection[] = mongoose.connections;

});
mongoose.createConnection(connectUri).openUri('');
mongoose.createConnection(connectUri, {
  db: {
    native_parser: true
  }
}).openUri('');
const dcWithCallback: void = mongoose.disconnect(cb);
const dcPromise: Promise<void> = mongoose.disconnect();
mongoose.get('test');
mongoose.model('Actor', new mongoose.Schema({
  name: String
}), 'collectionName', true).find({});
mongoose.model('Actor').find({});
mongoose.modelNames()[0].toLowerCase();
mongoose.models.Actor.findOne({}).exec();
new (new mongoose.Mongoose(9, 8, 7)).Mongoose(1, 2, 3).connect('');
mongoose.plugin(cb, {}).connect('');
mongoose.set('test', 'value');
mongoose.set('debug', function(collectionName: any, methodName: any, arg1: any, arg2: any) {});
mongoose.STATES.hasOwnProperty('');
mongoose.STATES.disconnected === 0;
mongoose.STATES.connected === 1;

mongoose.connection.on('error', cb);
new mongoose.mongo.MongoError('error').stack;
mongoose.SchemaTypes.String;
mongoose.SchemaTypes.ObjectId;
mongoose.SchemaTypes.Decimal128;
mongoose.SchemaTypes.Map;
mongoose.Types.ObjectId;
mongoose.Types.Decimal128;
mongoose.version.toLowerCase();

const sslConnections: {[key: string]: mongoose.Connection} = {
  basic: mongoose.createConnection(connectUri, {ssl: true}),
  customCA: mongoose.createConnection(
    connectUri,
    {
      ssl: true,
      sslCA: [new Buffer('ca string')],
      sslCRL: [new Buffer('crl buffer')],
      sslCert: 'ssl cert',
      sslKey: new Buffer('ssl private key'),
      sslPass: '<PASSWORD>',
      servername: 'localhost',
      checkServerIdentity: true,
      ciphers: 'ciphers',
      ecdhCurve: 'ecdhCurve',
    }
  ),
};

/*
 * section collection.js
 * http://mongoosejs.com/docs/api.html#collection-js
 *
 * section drivers/node-mongodb-native/collection.js
 * http://mongoosejs.com/docs/api.html#drivers-node-mongodb-native-collection-js
 */
var coll1 = <mongoose.Collection> {};
coll1.$format(999).toLowerCase();
coll1.$print('name', 'i', [1, 2, 3]);
coll1.getIndexes();
/* inherited properties */
coll1.collectionName;
coll1.conn;
coll1.name;
coll1.ensureIndex();
coll1.find({});
coll1.insert({}, {});

var coll2 = new mongoose.Collection('', new mongoose.Connection(mongoose));
coll2.$format(999).toLowerCase();
/* inherited properties */
coll2.initializeOrderedBulkOp;
coll2.indexExists;

/*
 * section connection.js
 * http://mongoosejs.com/docs/api.html#connection-js
 *
 * section section drivers/node-mongodb-native/connection.js
 * http://mongoosejs.com/docs/api.html#drivers-node-mongodb-native-connection-js
 */
var conn1: mongoose.Connection = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
conn1 = new mongoose.Connection(mongoose);
conn1.close().then(function () {}).catch(function (err) {});
conn1.close(true).then(function () {}).catch(function (err) {});
conn1.close(function (err) {});
conn1.close(true, function (err) {});
conn1.collection('name').$format(999);
conn1.model('myModel', new mongoose.Schema({}), 'myCol').find();
conn1.deleteModel('myModel');
conn1.models.myModel.findOne().exec();
interface IStatics {
  staticMethod1: (a: number) => string;
}
conn1.modelNames()[0].toLowerCase();
conn1.config.hasOwnProperty('');
conn1.db.bufferMaxEntries;
conn1.collections['coll'].$format(999);
conn1.readyState.toFixed();
conn1.name.toLowerCase()
conn1.host.toLowerCase()
conn1.port.toFixed()
conn1.useDb('myDb').useDb('');
mongoose.Connection.STATES.hasOwnProperty('');
mongoose.Connection.STATES.disconnected === 0;
mongoose.Connection.STATES.connected === 1;

/* inherited properties */
conn1.on('data', cb);
conn1.addListener('close', cb);

// The connection returned by useDb is *not* thenable.
// From https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26057#issuecomment-396150819
const getDB = async (tenant: string)=> {
  return conn1.useDb(tenant);
};

/*
 * section error.js
 * http://mongoosejs.com/docs/api.html#error-js
 */
var mongooseError: mongoose.Error = new mongoose.Error('error');
mongooseError.name;
/* inherited properties */
mongooseError.message;
mongooseError.stack;
/* static properties */
mongoose.Error.messages.hasOwnProperty('');
mongoose.Error.Messages.hasOwnProperty('');

/*
 * section error/cast.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.CastError
 */
var castError: mongoose.Error.CastError = new mongoose.Error.CastError('', '', '');
castError.name;
castError.stringValue;
castError.kind;
castError.path;
castError.value;
castError.setModel('foo');
/* inherited properties */
castError.message;
castError.stack;

/*
 * section error/validator.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.ValidatorError
 */
var validatorError: mongoose.Error.ValidatorError = new mongoose.Error.ValidatorError({ message: 'bar' })
validatorError.name;
validatorError.properties;
validatorError.kind;
validatorError.path;
validatorError.value;
validatorError.toString().toLowerCase();
validatorError.formatMessage('foo', {});
validatorError.formatMessage('foo', (bar: any)=>{ return bar; });
/* inherited properties */
validatorError.message;
validatorError.stack;

/*
 * section error/validation.js
 * https://mongoosejs.com/docs/api.html#mongooseerror_MongooseError.ValidationError
 */
var doc = <mongoose.Document>{};
var validationError: mongoose.Error.ValidationError | undefined = new mongoose.Error.ValidationError(doc);
validationError.name;
validationError.toString().toLowerCase();
validationError.inspect();
validationError.toJSON().hasOwnProperty('');
{'fraction_non_alphanumeric': 0.16931450426596056, 'fraction_numerical': 0.013459841129744042, 'mean_word_length': 5.7013307047806805, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2342251', 'n_tokens_mistral': 4411, 'n_tokens_neox': 4560, 'n_words': 746}