Socket
Socket
Sign inDemoInstall

api-supertest

Package Overview
Dependencies
163
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

28

lib/prepareItem.js

@@ -10,8 +10,12 @@ "use strict";

data = item.post;
delete item.post;
} else if (method === "PUT") {
data = item.put;
delete item.put;
} else if (method === "PATCH") {
data = item.patch;
delete item.patch;
} else if (method === "HEAD") {
data = item.head;
delete item.head;
}

@@ -34,5 +38,24 @@ return data || item.data;

}
if (item.get) {
return "GET";
}
return item.method ? item.method.toString().toUpperCase() : "GET";
}
function getPath(item) {
var path = item.path;
if (!path) {
path = "";
}
if (item.get) {
var queryIndex = path.indexOf("?");
if (queryIndex !== -1) {
path = path.substr(0, queryIndex);
}
path += "?" + item.get;
}
delete item.get;
return path;
}
function prepareItem(item, defaults) {

@@ -42,8 +65,5 @@ item = lodash.defaults(item, defaults);

item.data = getData(item, item.method);
item.path = getPath(item);
item.before = item.before || statePassthrough;
item.after = item.after || statePassthrough;
delete item.post;
delete item.put;
delete item.patch;
delete item.head;
return item;

@@ -50,0 +70,0 @@ }

2

package.json
{
"name": "api-supertest",
"version": "0.0.2",
"version": "0.0.3",
"description": "Beautiful test suite & runner for api tests.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -85,2 +85,3 @@ # API Supertest

push, put, post, head | Shortcuts to define a request as (eg.) post & with the given data (eg. ```post: "foo=bar&baz=boz"``` is the same as ```method: post``` and ```data: "foo=bar&baz=boz"```)
get | Adds a query string to the path. (replaces the query string if its already there). Add it without the leading "?": eg. ```foo=bar&baz=qux``` this will also set the method to ```get```.
json | [Joi](https://github.com/hapijs/joi) based json validator to be used for validating files

@@ -87,0 +88,0 @@ result | Result as a string to validate the content against. (Does not work in combination with ```json```). Can also be a [!!js/function](https://github.com/nodeca/js-yaml#user-content-supported-yaml-types) to perform your own tests.

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