Comparing version 0.7.1 to 0.8.0
0.8.0 / 2013-08-09 | ||
================== | ||
* add ability for multiple assertions per header | ||
0.7.1 / 2013-07-02 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -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 @@ |
{ | ||
"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 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
25643
667
1
6