format.js
This file
Path
test/acceptance/format.js
52 lines · 1.5 KiB · JavaScript
Last changed by
Updated format example with acceptance test.Robert Sköldbefore adoptioncd0e5db
History of this fileTake it
Updated format example with acceptance test.Robert Sköldbefore adoptioncd0e5db
lines 1–52why, one step back1var app = require('../../examples/format/app')2 , request = require('../support/http');34describe('format', function(){5 describe('GET /', function(){6 it('should respond with 200', function(done){7 request(app)8 .get('/')9 .expect(200,done)10 })11 })1213 describe('GET /item/2', function(){14 it('should respond with html', function(done){15 request(app)16 .get('/item/2')17 .end(function(res){18 res.should.have.property('statusCode',200)19 res.should.have.property('body','<h1>baz</h1>')20 res.headers.should.have.property('content-type','text/html; charset=utf-8')21 done()22 })23 })24 })2526 describe('GET /item/2.json', function(){27 it('should respond with json', function(done){28 request(app)29 .get('/item/2.json')30 .end(function(res){31 res.should.have.property('statusCode',200)32 res.should.have.property('body','{"name":"baz"}')33 res.headers.should.have.property('content-type','application/json; charset=utf-8')34 done()35 })36 })37 })3839 describe('GET /item/2.xml', function(){40 it('should respond with xml', function(done){41 request(app)42 .get('/item/2.xml')43 .end(function(res){44 res.should.have.property('statusCode',200)45 res.should.have.property('body','<items><item>baz</item></items>')46 res.headers.should.have.property('content-type','application/xml')47 done()48 })49 })50 })5152})