Skip to content
Myr

Updated error-pages example with acceptance test.

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

authored by Robert Sköld · committed by TJ Holowaychuk · parent 9d95645 · Browse files · 2 files+110 added−5 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+110 added−5 removed

  • tests:+101 added−0 removed
  • other:+9 added−5 removed

2 files+110 added−5 removed

modified:examples/error-pages/app.js+9 added-5 removed
added:test/acceptance/error-pages.js+101 added
1var app = require('../../examples/error-pages/app')2 , request = require('../support/http');34describe('error-pages', function(){5 describe('GET /', function(){6 it('should respond with page list', function(done){7 request(app)8 .get('/')9 .expect(/Pages Example/,done)10 })11 })1213 describe('Accept: text/html',function(){14 describe('GET /403', function(){15 it('should respond with 403', function(done){16 request(app)17 .get('/403')18 .expect(403,done)19 })20 })21 describe('GET /404', function(){22 it('should respond with 404', function(done){23 request(app)24 .get('/404')25 .expect(404,done)26 })27 })28 describe('GET /500', function(){29 it('should respond with 500', function(done){30 request(app)31 .get('/500')32 .expect(500,done)33 })34 })35 })363738 describe('Accept: application/json',function(){39 describe('GET /403', function(){40 it('should respond with 403', function(done){41 request(app)42 .get('/403')43 .set('Accept','application/json')44 .expect(403,done)45 })46 })47 describe('GET /404', function(){48 it('should respond with 404', function(done){49 request(app)50 .get('/404')51 .set('Accept','application/json')52 .end(function(res){53 res.should.have.property('statusCode',200)54 res.should.have.property('body',JSON.stringify({error:'Not found'}))55 done()56 })57 })58 })59 describe('GET /500', function(){60 it('should respond with 500', function(done){61 request(app)62 .get('/500')63 .set('Accept','application/json')64 .expect(500,done)65 })66 })67 })686970 describe('Accept: text/plain',function(){71 describe('GET /403', function(){72 it('should respond with 403', function(done){73 request(app)74 .get('/403')75 .set('Accept','text/plain')76 .expect(403,done)77 })78 })79 describe('GET /404', function(){80 it('should respond with 404', function(done){81 request(app)82 .get('/404')83 .set('Accept','text/plain')84 .end(function(res){85 res.should.have.property('statusCode',200)86 res.should.have.property('body','Not found')87 done()88 })89 })90 })91 describe('GET /500', function(){92 it('should respond with 500', function(done){93 request(app)94 .get('/500')95 .set('Accept','text/plain')96 .expect(500,done)97 })98 })99 })100101})