Socket
Socket
Sign inDemoInstall

api-test

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-test - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

classes/Case.js

30

index.js

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

* - context (default: {})
* - recursive (default: false)
*/

@@ -32,2 +33,3 @@ module.exports = function (folder, options) {

options.context.__proto__ = baseContext
options.recursive = options.recursive || false

@@ -47,5 +49,5 @@ options.describe('api', function () {

// Load files
fs.readdirSync(folder).forEach(function (item) {
if (item.substr(-3) === '.md') {
run(parse(fs.readFileSync(path.join(folder, item), 'utf8')), options)
walk(options.recursive, folder, function (file) {
if (file.substr(-3) === '.md') {
run(parse(fs.readFileSync(file, 'utf8')), options)
}

@@ -57,3 +59,4 @@ })

/**
*
* Make sure the mongo uri has 'localhost' as hostname and 'test' in the DB name
* @param {string} mongoUri
*/

@@ -90,2 +93,21 @@ function validateMongoUri(mongoUri) {

return mongoUri
}
/**
* Call a function for each file in a given directory
* @param {boolean} recursive
* @param {string} dir
* @param {Function} fn
*/
function walk(recursive, dir, fn) {
fs.readdirSync(dir).forEach(function (item) {
item = path.join(dir, item)
if (fs.statSync(item).isDirectory()) {
if (recursive) {
walk(recursive, item, fn)
}
} else {
fn(item)
}
})
}

6

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

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

"express": "^4.8.3",
"mocha": "^1.21.4",
"mongoose": "^3.8.14",
"should": "^4.0.4"
"mongoose": "^3.8.14"
}
}

@@ -37,9 +37,9 @@ /**

var Test = require('./Test'),
Obj = require('./Obj'),
Insertion = require('./Insertion'),
Clear = require('./Clear'),
Declaration = require('./Declaration'),
Case = require('./Case'),
Find = require('./Find')
var Test = require('./classes/Test'),
Obj = require('./classes/Obj'),
Insertion = require('./classes/Insertion'),
Clear = require('./classes/Clear'),
Declaration = require('./classes/Declaration'),
Case = require('./classes/Case'),
Find = require('./classes/Find')

@@ -46,0 +46,0 @@ /**

@@ -130,2 +130,3 @@ # API Test

* `context`: (optional) define your own variables/functions accessible to object definitions
* `recursive`: (optional) whether to look for *.md files inside subfolders (default: false)

@@ -159,3 +160,3 @@ ## Custom context

Instead of repeating youself with:
Instead of repeating yourself with:
```

@@ -171,3 +172,3 @@ error:

## Run test
Run `node index` in 'test/api' to start the a simple API webservice. Then (in another terminal instance), run `npm test` in the project root folder.
Run `npm test` in the project root folder.

@@ -174,0 +175,0 @@ ## TODO

@@ -0,1 +1,2 @@

/*globals before*/
'use strict'

@@ -5,5 +6,12 @@

before(function () {
// Start the API
this.timeout(5e3)
require('./api')
})
test('test/api-test', {
mongoUri: 'mongodb://localhost:27017/api_test',
baseUrl: 'http://localhost:8000/'
baseUrl: 'http://localhost:8000/',
recursive: true
})
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc