Socket
Socket
Sign inDemoInstall

api-test

Package Overview
Dependencies
82
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.0 to 2.4.0

37

classes/Insertion.js

@@ -15,4 +15,6 @@ 'use strict'

this.name = name
/** @member {string} */
this.collection = collection
/** @member {Obj} */

@@ -34,2 +36,6 @@ this.value = value

value = this.value.execute(context, '<' + this.name + ' in ' + this.collection + '>')
if (context.defaultDocuments[this.collection]) {
setDefaults(value, context.defaultDocuments[this.collection])
}
context[that.name] = copyDeep(value)

@@ -52,4 +58,3 @@ db.collection(this.collection).insert(context[that.name], {

return x.map(copyDeep)
} else if (x && typeof x === 'object' &&
(x.constructor === Object || !Object.getPrototypeOf(x))) {
} else if (isObject(x)) {
// Map

@@ -64,2 +69,30 @@ r = Object.create(null)

}
}
/**
* @param {Object} value
* @param {Object} defaults
*/
function setDefaults(value, defaults) {
var key
for (key in defaults) {
if (!(key in value)) {
// Not present, simply set
// No need to copyDeep here because it will be done after
// setDefaults returns
value[key] = defaults[key]
} else if (isObject(value[key]) && isObject(defaults[key])) {
// Recurse
setDefaults(value[key], defaults[key])
}
}
}
/**
* @param {*} x
* @returns {boolean}
*/
function isObject(x) {
return x && typeof x === 'object' && (x.constructor === Object || !Object.getPrototypeOf(x))
}

@@ -33,2 +33,3 @@ /*globals describe, before, it*/

* @param {Function} [options.it]
* @param {Object<String, Object>} [options.defaultDocuments]
*/

@@ -38,2 +39,5 @@ module.exports = function (folder, options) {

// Save defaultDocuments to baseContext to make it available for the script
baseContext.defaultDocuments = options.defaultDocuments || Object.create(null)
// Prepare options

@@ -40,0 +44,0 @@ options.describe = options.describe || describe

16

package.json
{
"name": "api-test",
"version": "2.3.0",
"version": "2.4.0",
"author": "Sitegui <sitegui@sitegui.com.br>",

@@ -19,6 +19,6 @@ "description": "API testing made simple",

"async": "^0.9.0",
"mocha": "^2.1.0",
"mongodb": "^1.4.33",
"request": "^2.53.0",
"should": "^5.0.1"
"mocha": "^2.2.1",
"mongodb": "^2.0.25",
"request": "^2.54.0",
"should": "^5.2.0"
},

@@ -33,6 +33,6 @@ "license": "MIT",

"devDependencies": {
"body-parser": "^1.12.0",
"express": "^4.12.2",
"mongoose": "^3.8.24"
"body-parser": "^1.12.2",
"express": "^4.12.3",
"mongoose": "^4.0.1"
}
}

@@ -63,4 +63,6 @@ # API Test

The syntax for _docDescription_ is described bellow
The syntax for _docDescription_ is described bellow.
Most of times, documents have a base strucuture with some default fields. You do not need to repeat yourself in this case, see the option `defaultDocuments` bellow.
#### Clearing collections

@@ -148,2 +150,3 @@ The syntax is simply:

* `baseUrl`: the base API url. Every request url will be composed from this base and the test name.
* `defaultDocuments`: (optional) the default structure for documents in each collection. See [issue #1](https://github.com/clubedaentrega/api-test/issues/1) for details
* `describe`, `it`, `before`: (optional) the mocha interface. Defaults to global mocha functions

@@ -150,0 +153,0 @@ * `context`: (optional) define your own variables/functions accessible to object definitions

@@ -7,4 +7,5 @@ # user/signup

### user is
name: 'Guilherme'
password: '1234'
defaultDocuments.users with
name: 'Guilherme'
password: '1234'

@@ -11,0 +12,0 @@ ## Invalid username

@@ -8,4 +8,5 @@ # Signup + Login

### user is
name: 'Guilherme'
password: '12345'
defaultDocuments.users with
name: 'Guilherme'
password: '12345'

@@ -12,0 +13,0 @@ ## Signup

@@ -19,3 +19,7 @@ 'use strict'

password: String,
token: String
token: String,
isActive: {
type: Boolean,
default: true
}
}))

@@ -86,2 +90,4 @@

token: String(Math.random())
}, {
new: true
}, function (err, user) {

@@ -88,0 +94,0 @@ if (err) {

@@ -15,3 +15,8 @@ /*globals before*/

baseUrl: 'http://localhost:8000/',
recursive: true
recursive: true,
defaultDocuments: {
users: {
isActive: true
}
}
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc