app.options.js
This file
Path
test/app.options.js
61 lines · 1.4 KiB · JavaScript
Last changed by
remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
History of this fileTake it
The walk stopped after 200 commits: lines older than 34c83d7 point at it.
3.4.7Jonathan Ongbefore adoption34c83d7
lines 1–2why, one step back12var express = require('../')remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 3why, one step back3 , request = require('supertest');3.4.7Jonathan Ongbefore adoption34c83d7
lines 4–17why, one step back45describe('OPTIONS', function(){6 it('should default to the routes defined', function(done){7 var app = express();89 app.del('/', function(){});10 app.get('/users', function(req, res){});11 app.put('/users', function(req, res){});1213 request(app)14 .options('/users')15 .expect('GET,PUT')16 .expect('Allow', 'GET,PUT', done);17 })Merge pull request #1868 from dpatti/smarter-router-auto-optionsRoman Shtylmanbefore adoption5ddbb69
lines 18–33why, one step back1819 it('should not respond if the path is not defined', function(done){20 var app = express();2122 app.get('/users', function(req, res){});2324 request(app)25 .options('/other')26 .expect(404, done);27 })2829 it('should forward requests down the middleware chain', function(done){30 var app = express();31 var router = new express.Router();3233 router.get('/users', function(req, res){});make express.Router() return a Router function instanceRoman Shtylmanbefore adoptionf8b954b
line 34why, one step back34 app.use(router);Merge pull request #1868 from dpatti/smarter-router-auto-optionsRoman Shtylmanbefore adoption5ddbb69
lines 35–41why, one step back35 app.get('/other', function(req, res){});3637 request(app)38 .options('/other')39 .expect('GET')40 .expect('Allow', 'GET', done);41 })3.4.7Jonathan Ongbefore adoption34c83d7
lines 42–61why, one step back42})4344describe('app.options()', function(){45 it('should override the default behavior', function(done){46 var app = express();4748 app.options('/users', function(req, res){49 res.set('Allow', 'GET');50 res.send('GET');51 });5253 app.get('/users', function(req, res){});54 app.put('/users', function(req, res){});5556 request(app)57 .options('/users')58 .expect('GET')59 .expect('Allow', 'GET', done);60 })61})