Skip to content
Myr

tests: use supertest to perform assertions

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 dc538f6 · Browse files · 3 files+15 added−26 removed
This commit

State

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

Diff stats

3 files+15 added−26 removed

  • tests:+15 added−26 removed

3 files+15 added−26 removed

modified:test/app.router.js+9 added-15 removed
150 unmodified lines
151 });152153 app.use(function(req, res, next){154 calls.push('after');155 res.end();155 res.json(calls)156 });157158 request(app)159 .get('/')160 .end(function(res){161 calls.should.eql(['before', 'GET /', 'after'])162 done();163 })160 .expect(200, ['before', 'GET /', 'after'], done)161 })162163 describe('when given a regexp', function(){164 it('should match the pathname only', function(done){
722 unmodified lines
887 });888889 app.get('/foo', function(req, res, next){890 calls.push('/foo 2');894 res.end('done');891 res.json(calls)892 });893894 request(app)895 .get('/foo')899 .expect('done', function(){900 calls.should.eql(['/foo/:bar?', '/foo', '/foo 2']);901 done();902 })896 .expect(200, ['/foo/:bar?', '/foo', '/foo 2'], done)897 })898 })899900 describe('when next("route") is called', function(){
74 unmodified lines
975 assert(0);976 });977978 app.use(function(err, req, res, next){985 res.end(err.message);979 res.json({980 calls: calls,981 error: err.message982 })983 })984985 request(app)986 .get('/foo')990 .expect('fail', function(){991 calls.should.eql(['/foo/:bar?', '/foo']);992 done();993 })987 .expect(200, { calls: ['/foo/:bar?', '/foo'], error: 'fail' }, done)988 })989990 it('should call handler in same route, if exists', function(done){991 var app = express();
87 unmodified lines
modified:test/res.cookie.js+2 added-5 removed
modified:test/res.locals.js+4 added-6 removed
6 unmodified lines
7 it('should be empty by default', function(done){8 var app = express();910 app.use(function(req, res){11 Object.keys(res.locals).should.eql([]);12 res.end();11 res.json(res.locals)12 });1314 request(app)15 .get('/')17 .expect(200, done);16 .expect(200, {}, done)17 })18 })1920 it('should work when mounted', function(done){
7 unmodified lines
28 next();29 });3031 app.use(function(req, res){33 res.locals.foo.should.equal('bar');34 res.end();32 res.json(res.locals)33 });3435 request(app)36 .get('/')39 .expect(200, done);37 .expect(200, { foo: 'bar' }, done)38 })39})