tests: fixup new json 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 3d6b4ba · Browse files · 2 files·+42 added−36 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+42 added−36 removed
- tests:+42 added−36 removed
Provenance
- Commit
e4302b2- Tree
a43cdde- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
3d6b4ba
2 files changed+42 added−36 removed
modified:test/res.json.js+14 added-18 removed
15 unmodified lines16171819202122232425262728293031323334353637131 unmodified linesExpand all16917017117215916016116216316416516616716816917017117217317417517617315 unmodified lines .get('/?callback=foo') .expect('{"foo":"bar"}', done); })
it('should not override previous Content-Types', function(done){ var app = express();
app.get('/', function(req, res){ res.type('application/vnd.example+json'); res.json({ hello: 'world' }); });
request(app) .get('/') .expect('Content-Type', 'application/vnd.example+json') .expect(200, '{"hello":"world"}', done); })
describe('when given primitives', function(){ it('should respond with json', function(done){ var app = express();
131 unmodified linesExpand all done(); }) }) })
it('should not override previous Content-Types', function(done){ var app = express();
app.get('/', function(req, res){ res.type('application/vnd.example+json'); res.json({ 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(); }) })})modified:test/res.jsonp.js+28 added-18 removed
117 unmodified lines118 done();119 });120 });121 122+ it('should not override previous Content-Types with no callback', function(done){123+ var app = express();124+125+ app.get('/', function(req, res){126+ res.type('application/vnd.example+json');127+ res.jsonp({ hello: 'world' });128+ });129+130+ request(app)131+ .get('/')132+ .expect('Content-Type', 'application/vnd.example+json')133+ .expect(200, '{"hello":"world"}', done);134+ })135+136+ it('should override previous Content-Types with callback', function(done){137+ var app = express();138+139+ app.get('/', function(req, res){140+ res.type('application/vnd.example+json');141+ res.jsonp({ hello: 'world' });142+ });143+144+ request(app)145+ .get('/?callback=cb')146+ .expect('Content-Type', 'text/javascript; charset=utf-8')147+ .expect(200, /cb\(\{"hello":"world"\}\);$/, done);148+ })149+150 describe('when given primitives', function(){151 it('should respond with json', function(done){152 var app = express();153 131 unmodified lines285 done();286 })287 })288 })261-262- it('should not override previous Content-Types', function(done){263- var app = express();264-265- app.get('/', function(req, res){266- res.type('application/vnd.example+json');267- res.jsonp({ hello: 'world' });268- });269-270- request(app)271- .get('/')272- .end(function(err, res){273- res.statusCode.should.equal(200);274- res.headers.should.have.property('content-type', 'application/vnd.example+json');275- res.text.should.equal('{"hello":"world"}');276- done();277- })278- })289 })