tests: fixup new json tests

This commit is contained in:
Douglas Christopher Wilson
2014-05-08 23:22:18 -04:00
parent 3d6b4ba013
commit e4302b2120
2 changed files with 42 additions and 36 deletions

View File

@@ -119,6 +119,34 @@ describe('res', function(){
});
});
it('should not override previous Content-Types with no callback', function(done){
var app = express();
app.get('/', function(req, res){
res.type('application/vnd.example+json');
res.jsonp({ hello: 'world' });
});
request(app)
.get('/')
.expect('Content-Type', 'application/vnd.example+json')
.expect(200, '{"hello":"world"}', done);
})
it('should override previous Content-Types with callback', function(done){
var app = express();
app.get('/', function(req, res){
res.type('application/vnd.example+json');
res.jsonp({ hello: 'world' });
});
request(app)
.get('/?callback=cb')
.expect('Content-Type', 'text/javascript; charset=utf-8')
.expect(200, /cb\(\{"hello":"world"\}\);$/, done);
})
describe('when given primitives', function(){
it('should respond with json', function(done){
var app = express();
@@ -258,22 +286,4 @@ describe('res', function(){
})
})
})
it('should not override previous Content-Types', function(done){
var app = express();
app.get('/', function(req, res){
res.type('application/vnd.example+json');
res.jsonp({ hello: 'world' });
});
request(app)
.get('/')
.end(function(err, res){
res.statusCode.should.equal(200);
res.headers.should.have.property('content-type', 'application/vnd.example+json');
res.text.should.equal('{"hello":"world"}');
done();
})
})
})