Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added jsonp test

  • Loading branch information...
commit 9af3256f727cbfe81a3aab47a73dd746f652ed88 1 parent cdd333a
@tj tj authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/res.json.js
View
19 test/res.json.js
@@ -5,6 +5,25 @@ var express = require('../')
describe('res', function(){
describe('.json(object)', function(){
+ describe('when "jsonp callback" is enabled', function(){
+ it('should respond with jsonp', function(done){
+ var app = express();
+
+ app.enable('jsonp callback');
+ app.use(function(req, res){
+ res.json({ count: 1 });
+ });
+
+ request(app)
+ .get('/?callback=something')
+ .end(function(res){
+ res.headers.should.have.property('content-type', 'text/javascript; charset=utf-8');
+ res.body.should.equal('something({"count":1});');
+ done();
+ })
+ })
+ })
+
describe('when given primitives', function(){
it('should respond with json', function(done){
var app = express();
Please sign in to comment.
Something went wrong with that request. Please try again.