/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/api-test@4.1.0/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var parseFile=require("./parseFile"),fs=require("fs"),path=require("path"),MongoClient=require("mongodb").MongoClient,baseContext=require("./baseContext"),parseUrl=require("url").parse,crypto=require("crypto");function validateMongoUri(e){var t,o,r;if(e.match(/^![a-z0-9]{10}!/)&&(t=e.substr(1,10),e=e.substr(12)),-1!==e.indexOf("test")&&"localhost"===parseUrl(e).hostname||((r=crypto.createHash("sha1")).end(new Buffer(e)),o=r.read().toString("hex").substr(0,10)),t!==o)throw console.log("++++++++++"),o?(console.log('The mongoUri "'+e.substr(0,17)+'..." seems not to be test-safe'),console.log('I recommend you to connect to a localhost instance and a database with "test" in the name'),console.log("Remember that the database is DROPPED before every test!"),console.log('If you are really sure, please prepend "!'+o+'!" to your mongoUri'),console.log('Like this: "!'+o+"!"+e.substr(0,17)+'..."')):console.log("Please remove the !tag! from the mongoUri to run the test"),console.log("++++++++++"),new Error("Invalid protection tag");return e}function walk(e,t,o){fs.readdirSync(t).forEach((function(r){r=path.join(t,r),fs.statSync(r).isDirectory()?e&&walk(e,r,o):o(r)}))}module.exports=function(e,t){t.mongoUri=validateMongoUri(t.mongoUri),baseContext.defaultDocuments=t.defaultDocuments||Object.create(null),t.name=t.name||"api",t.describe=t.describe||describe,t.before=t.before||before,t.it=t.it||it,t.context=t.context||{},t.context.__proto__=baseContext,t.recursive=t.recursive||!1,t.strict=void 0===t.strict||t.strict,t.filterFile=t.filterFile||function(){return!0},t.ignoredFindKeys=t.ignoredFindKeys||["_id","__v"],t.describe(t.name,(function(){t.before((function(e){MongoClient.connect(t.mongoUri,(function(o,r){if(o)return e(o);t.db=r,e()}))})),walk(t.recursive,e,(function(e){if(".md"===e.substr(-3)&&t.filterFile(e)){var o=parseFile(e);t.onTest&&t.onTest(o),o.execute(t)}}))}))};
//# sourceMappingURL=/sm/6adb7cf2db100edadba17ca02eabaf23e5176faeb1d5bfdae9e9fb8733a32752.map