Skip to content
Myr

tests: add more res.jsonp? tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 35a66d8 · Browse files · 2 files+87 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+87 added−1 removed

  • tests:+87 added−1 removed

2 files+87 added−1 removed

modified:test/res.json.js+35 added-1 removed
16 unmodified lines
17 .expect('{"foo":"bar"}', done);18 })1920 describe('when given primitives', function(){21 it('should respond with json', function(done){21 it('should respond with json for null', function(done){22 var app = express();2324 app.use(function(req, res){25 res.json(null);
6 unmodified lines
32 res.text.should.equal('null');33 done();34 })35 })3637 it('should respond with json for Number', function(done){38 var app = express();3940 app.use(function(req, res){41 res.json(300);42 });4344 request(app)45 .get('/')46 .end(function(err, res){47 res.statusCode.should.equal(200);48 res.headers.should.have.property('content-type', 'application/json; charset=utf-8');49 res.text.should.equal('300');50 done();51 })52 })5354 it('should respond with json for String', function(done){55 var app = express();5657 app.use(function(req, res){58 res.json('str');59 });6061 request(app)62 .get('/')63 .end(function(err, res){64 res.statusCode.should.equal(200);65 res.headers.should.have.property('content-type', 'application/json; charset=utf-8');66 res.text.should.equal('"str"');67 done();68 })69 })70 })7172 describe('when given an array', function(){73 it('should respond with json', function(done){
162 unmodified lines
modified:test/res.jsonp.js+52 added
171 unmodified lines
172 })173 })174 })175176 describe('when given primitives', function(){177 it('should respond with json for null', function(done){178 var app = express();179180 app.use(function(req, res){181 res.jsonp(null);182 });183184 request(app)185 .get('/')186 .end(function(err, res){187 res.headers.should.have.property('content-type', 'application/json; charset=utf-8');188 res.text.should.equal('null');189 done();190 })191 })192193 it('should respond with json for Number', function(done){194 var app = express();195196 app.use(function(req, res){197 res.jsonp(300);198 });199200 request(app)201 .get('/')202 .end(function(err, res){203 res.statusCode.should.equal(200);204 res.headers.should.have.property('content-type', 'application/json; charset=utf-8');205 res.text.should.equal('300');206 done();207 })208 })209210 it('should respond with json for String', function(done){211 var app = express();212213 app.use(function(req, res){214 res.jsonp('str');215 });216217 request(app)218 .get('/')219 .end(function(err, res){220 res.statusCode.should.equal(200);221 res.headers.should.have.property('content-type', 'application/json; charset=utf-8');222 res.text.should.equal('"str"');223 done();224 })225 })226 })227228 describe('"json replacer" setting', function(){229 it('should be passed to JSON.stringify()', function(done){230 var app = express();231
106 unmodified lines