Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

should-http

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

should-http - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

7

History.md

@@ -1,4 +0,9 @@

0.0.1 / 2014-05-29
0.0.3 / 2015-05-21
==================
* .status will show only body and statusCode
0.0.2 / 2014-05-29
==================
* Fix for current should.js version

@@ -5,0 +10,0 @@

@@ -10,2 +10,15 @@ /*!

/**
* Asserts given object has property headers which contain `field` and optional `val`. Will work well with node Request/Response etc.
*
* @name header
* @memberOf Assertion
* @category assertion http
* @module should-http
* @param {string} field Name of field
* @param {string} [val] Optional value of field
* @example
*
* res.should.have.header('content-type', 'application/json');
*/
Assertion.add('header', function(field, val) {

@@ -21,9 +34,32 @@ this.have.property('headers');

/**
* Asserts given object has property statusCode which equal to `code`. Works well with node's Response.
*
* @name status
* @memberOf Assertion
* @category assertion http
* @module should-http
* @param {number} code Status code value
* @example
*
* res.should.have.status(200);
*/
Assertion.add('status', function(code) {
//this.params = { operator: 'to have response code ' + code + ' ' + i(statusCodes[code])
// + ', but got ' + this.obj.statusCode + ' ' + i(statusCodes[this.obj.statusCode]) }
var obj = this.obj;
var copy = { body: obj.body, statusCode: obj.statusCode };
this.have.property('statusCode', code);
copy.should.have.property('statusCode', code);
});
/**
* Shortcut for .should.header('content-type', 'application/json')
*
* @name json
* @memberOf Assertion
* @category assertion http
* @module should-http
* @example
*
* res.should.be.json;
*/
Assertion.add('json', function() {

@@ -33,2 +69,13 @@ this.have.header('content-type').match(/application\/json/i);

/**
* Shortcut for .should.header('content-type', 'text/html')
*
* @name html
* @memberOf Assertion
* @category assertion http
* @module should-http
* @example
*
* res.should.be.json;
*/
Assertion.add('html', function() {

@@ -35,0 +82,0 @@ this.have.header('content-type').match(/text\/html/i);

2

package.json
{
"name": "should-http",
"version": "0.0.2",
"version": "0.0.3",
"description": "Http requests, response assertions for should.js",

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

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