added first batch of acceptance tests for examples
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 39ae443 · Browse files · 3 files·+67 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
3 files+67 added−5 removed
- tests:+54 added−0 removed
- other:+13 added−5 removed
Provenance
- Commit
29ef828- Tree
1e19895- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
39ae443
3 files changed+67 added−5 removed
modified:examples/content-negotiation/app.js+9 added-4 removed
12345676789101112131431 unmodified lines4647484950514849525354
/** * Module dependencies. */
var express = require('../../') , app = express();var express = require('../../');
// expose the app for require()ingvar app = module.exports = express();
var users = [ { name: 'tobi' } , { name: 'loki' } , { name: 'jane' }31 unmodified lines return user.name; }).join(', '));});
// not being require()dif (!module.parent) {app.listen(3000);console.log('Express server listening on port 3000'); app.listen(3000); console.log('Express server listening on port 3000');}added:test/acceptance/content-negotiation.js+54 added
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
var request = require('../support/http') , app = require('../../examples/content-negotiation/app');
describe('content-negotiation', function(){ describe('GET /users', function(){ it('should support json', function(done){ request(app) .get('/users') .set('Accept', 'application/json') .end(function(res){ res.should.have.header('Content-Type', 'application/json; charset=utf-8'); res.should.have.status(200); res.body.should.equal('[{"name":"tobi"},{"name":"loki"},{"name":"jane"}]'); done(); }); })
it('should support html', function(done){ request(app) .get('/users') .set('Accept', 'text/html') .end(function(res){ res.should.have.header('Content-Type', 'text/html; charset=utf-8'); res.should.have.status(200); res.body.should.equal('<ul><li>tobi</li>\n<li>loki</li>\n<li>jane</li></ul>'); done(); }); })
it('should support plain text', function(done){ request(app) .get('/users') .set('Accept', 'text/plain') .end(function(res){ res.should.have.header('Content-Type', 'text/plain'); res.should.have.status(200); res.body.should.equal('tobi, loki, jane'); done(); }); })
it('should default to application/json', function(done){ request(app) .get('/users') .end(function(res){ res.should.have.header('Content-Type', 'application/json; charset=utf-8'); res.should.have.status(200); res.body.should.equal('[{"name":"tobi"},{"name":"loki"},{"name":"jane"}]'); done(); }); }) })})No newline at end of filemodified:Makefile+4 added-1 removed
10 unmodified lines11 --slow 20 \12 --growl \13 $(TESTS)14 15+test-acceptance:16+ @$(MAKE) test TESTS=test/acceptance/*.js17+18 docs: $(HTMLDOCS)19 @ echo "... generating TOC"20 @./support/toc.js docs/guide.html21 15 unmodified lines37 38 docclean:39 rm -f docs/*.{1,html}40 38-.PHONY: site test benchmark docs docclean41+.PHONY: site test benchmark docs docclean test-acceptance