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

supertest

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

5

History.md
0.8.0 / 2013-08-09
==================
* add ability for multiple assertions per header
0.7.1 / 2013-07-02

@@ -3,0 +8,0 @@ ==================

20

lib/test.js

@@ -96,3 +96,4 @@

if ('string' == typeof b || b instanceof RegExp) {
this._fields[a] = b;
if (!this._fields[a]) this._fields[a] = [];
this._fields[a].push(b);
return this;

@@ -137,3 +138,3 @@ }

, bodies = this._bodies
, expected
, expecteds
, actual

@@ -182,10 +183,13 @@ , re;

for (var field in fields) {
expected = fields[field];
expecteds = fields[field];
actual = res.header[field.toLowerCase()];
if (null == actual) return fn(new Error('expected "' + field + '" header field'));
if (expected == actual) continue;
if (expected instanceof RegExp) re = expected;
if (re && re.test(actual)) continue;
if (re) return fn(new Error('expected "' + field + '" matching ' + expected + ', got "' + actual + '"'));
return fn(new Error('expected "' + field + '" of "' + expected + '", got "' + actual + '"'));
for (var i = 0; i < expecteds.length; i++) {
var fieldExpected = expecteds[i];
if (fieldExpected == actual) continue;
if (fieldExpected instanceof RegExp) re = fieldExpected;
if (re && re.test(actual)) continue;
if (re) return fn(new Error('expected "' + field + '" matching ' + fieldExpected + ', got "' + actual + '"'));
return fn(new Error('expected "' + field + '" of "' + fieldExpected + '", got "' + actual + '"'));
}
}

@@ -192,0 +196,0 @@

8

package.json
{
"name": "supertest",
"version": "0.7.1",
"version": "0.8.0",
"description": "Super-agent driven library for testing HTTP servers",

@@ -28,3 +28,7 @@ "main": "index.js",

"author": "TJ Holowaychuk",
"license": "MIT"
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/visionmedia/supertest.git"
}
}

@@ -387,2 +387,70 @@

})
describe('handling multiple assertions per field', function(){
it('should work', function(done){
var app = express();
app.get('/', function(req, res){
res.send('hey');
});
request(app)
.get('/')
.expect('Content-Type', /text/)
.expect('Content-Type', /html/)
.end(done);
});
it('should return an error if the first one fails', function(done){
var app = express();
app.get('/', function(req, res){
res.send('hey');
});
request(app)
.get('/')
.expect('Content-Type', /bloop/)
.expect('Content-Type', /html/)
.end(function(err){
err.message.should.equal('expected "Content-Type" matching /bloop/, got "text/html; charset=utf-8"');
done();
});
});
it('should return an error if a middle one fails', function(done){
var app = express();
app.get('/', function(req, res){
res.send('hey');
});
request(app)
.get('/')
.expect('Content-Type', /text/)
.expect('Content-Type', /bloop/)
.expect('Content-Type', /html/)
.end(function(err){
err.message.should.equal('expected "Content-Type" matching /bloop/, got "text/html; charset=utf-8"');
done();
});
});
it('should return an error if the last one fails', function(done){
var app = express();
app.get('/', function(req, res){
res.send('hey');
});
request(app)
.get('/')
.expect('Content-Type', /text/)
.expect('Content-Type', /html/)
.expect('Content-Type', /bloop/)
.end(function(err){
err.message.should.equal('expected "Content-Type" matching /bloop/, got "text/html; charset=utf-8"');
done();
});
});
});
})

@@ -389,0 +457,0 @@ })

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