Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add header field presence support

  • Loading branch information...
commit e32f49bc3cd9e58b168c3fe5440a8e5546d5dc8a 1 parent 24e6a5d
@tj tj authored
Showing with 17 additions and 0 deletions.
  1. +1 −0  lib/test.js
  2. +16 −0 test/supertest.js
View
1  lib/test.js
@@ -126,6 +126,7 @@ Test.prototype.assert = function(res, fn){
for (var field in fields) {
expected = fields[field];
actual = res.header[field.toLowerCase()];
+ if (null == actual) return fn(new Error('expected "' + field + '" header field'));
if (expected == actual) continue;
return fn(new Error('expected "' + field + '" of "' + expected + '", got "' + actual + '"'));
}
View
16 test/supertest.js
@@ -76,6 +76,22 @@ describe('request(app)', function(){
})
describe('.expect(field, value[, fn])', function(){
+ it('should assert the header field presence', function(done){
+ var app = express();
+
+ app.get('/', function(req, res){
+ res.send({ foo: 'bar' });
+ });
+
+ request(app)
+ .get('/')
+ .expect('Content-Foo', 'bar')
+ .end(function(err, res){
+ err.message.should.equal('expected "Content-Foo" header field');
+ done();
+ });
+ })
+
it('should assert the header field value', function(done){
var app = express();
Please sign in to comment.
Something went wrong with that request. Please try again.