Skip to content
Myr

tests: use supertest expect for simple 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 7027b37 · Browse files · 5 files+19 added−42 removed
This commit

State

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

Diff stats

5 files+19 added−42 removed

  • tests:+19 added−42 removed

5 files+19 added−42 removed

modified:test/app.param.js+4 added-5 removed
27 unmodified lines
28 });2930 request(app)31 .get('/user/tj')32 .end(function(err, res){33 res.text.should.equal('tj');32 .expect(200, 'tj', function (err) {33 if (err) return done(err)34 request(app)35 .get('/user/123')36 .expect(404, done);37 });
30 unmodified lines
68 });6970 request(app)71 .get('/user/123')72 .end(function(err, res){73 res.text.should.equal('123');7472 .expect(200, '123', function (err) {73 if (err) return done(err)74 request(app)75 .get('/post/123')76 .expect('123', done);77 })
289 unmodified lines
modified:test/app.router.js+2 added-2 removed
537 unmodified lines
538 });539540 request(app)541 .get('/user/10')542 .end(function(err, res){543 res.statusCode.should.equal(200);542 .expect(200, function (err) {543 if (err) return done(err)544 request(app)545 .get('/user/tj')546 .expect(404, done);547 });
542 unmodified lines
modified:test/req.signedCookies.js+1 added-5 removed
modified:test/res.clearCookie.js+4 added-10 removed
modified:test/res.cookie.js+8 added-20 removed
14 unmodified lines
15 });1617 request(app)18 .get('/')19 .end(function(err, res){20 var val = ['user=' + encodeURIComponent('j:{"name":"tobi"}') + '; Path=/'];21 res.headers['set-cookie'].should.eql(val);22 done();23 })19 .expect('Set-Cookie', 'user=j%3A%7B%22name%22%3A%22tobi%22%7D; Path=/')20 .expect(200, done)21 })22 })2324 describe('.cookie(name, string)', function(){
5 unmodified lines
30 });3132 request(app)33 .get('/')37 .end(function(err, res){38 var val = ['name=tobi; Path=/'];39 res.headers['set-cookie'].should.eql(val);40 done();41 })34 .expect('Set-Cookie', 'name=tobi; Path=/')35 .expect(200, done)36 })3738 it('should allow multiple calls', function(done){39 var app = express();
25 unmodified lines
65 });6667 request(app)68 .get('/')75 .end(function(err, res){76 var val = ['name=tobi; Path=/; HttpOnly; Secure'];77 res.headers['set-cookie'].should.eql(val);78 done();79 })69 .expect('Set-Cookie', 'name=tobi; Path=/; HttpOnly; Secure')70 .expect(200, done)71 })7273 describe('maxAge', function(){74 it('should set relative expires', function(done){
93 unmodified lines
168 });169170 request(app)171 .get('/')181 .end(function(err, res){182 var val = ['name=s%3Atobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; Path=/'];183 res.headers['set-cookie'].should.eql(val);184 done();185 })172 .expect('Set-Cookie', 'name=s%3Atobi.xJjV2iZ6EI7C8E5kzwbfA9PVLl1ZR07UTnuTgQQ4EnQ; Path=/')173 .expect(200, done)174 })175 })176 })177})