req.xhr.js
This file
Path
test/req.xhr.js
74 lines · 1.5 KiB · JavaScript
Last changed by
Merge pull request #2053 from shawnzhu/fix-xhr-testRoman Shtylmanbefore adoption5f1d577
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('req', function(){6 describe('.xhr', function(){7 it('should return true when X-Requested-With is xmlhttprequest', function(done){8 var app = express();910 app.use(function(req, res){11 req.xhr.should.be.true;12 res.end();13 });1415 request(app)16 .get('/')17 .set('X-Requested-With', 'xmlhttprequest')Merge pull request #2053 from shawnzhu/fix-xhr-testRoman Shtylmanbefore adoption5f1d577
lines 18–20why, one step back18 .expect(200)19 .end(function(err, res){20 done(err);3.4.7Jonathan Ongbefore adoption34c83d7
lines 21–22why, one step back21 })22 })remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 23why, one step back233.4.7Jonathan Ongbefore adoption34c83d7
lines 24–34why, one step back24 it('should case-insensitive', function(done){25 var app = express();2627 app.use(function(req, res){28 req.xhr.should.be.true;29 res.end();30 });3132 request(app)33 .get('/')34 .set('X-Requested-With', 'XMLHttpRequest')Merge pull request #2053 from shawnzhu/fix-xhr-testRoman Shtylmanbefore adoption5f1d577
lines 35–37why, one step back35 .expect(200)36 .end(function(err, res){37 done(err);3.4.7Jonathan Ongbefore adoption34c83d7
lines 38–39why, one step back38 })39 })remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 40why, one step back403.4.7Jonathan Ongbefore adoption34c83d7
lines 41–51why, one step back41 it('should return false otherwise', function(done){42 var app = express();4344 app.use(function(req, res){45 req.xhr.should.be.false;46 res.end();47 });4849 request(app)50 .get('/')51 .set('X-Requested-With', 'blahblah')Merge pull request #2053 from shawnzhu/fix-xhr-testRoman Shtylmanbefore adoption5f1d577
lines 52–54why, one step back52 .expect(200)53 .end(function(err, res){54 done(err);3.4.7Jonathan Ongbefore adoption34c83d7
lines 55–56why, one step back55 })56 })remove unnecessary test/support/httpJonathan Ongbefore adoption643397e
line 57why, one step back573.4.7Jonathan Ongbefore adoption34c83d7
lines 58–67why, one step back58 it('should return false when not present', function(done){59 var app = express();6061 app.use(function(req, res){62 req.xhr.should.be.false;63 res.end();64 });6566 request(app)67 .get('/')Merge pull request #2053 from shawnzhu/fix-xhr-testRoman Shtylmanbefore adoption5f1d577
lines 68–70why, one step back68 .expect(200)69 .end(function(err, res){70 done(err);3.4.7Jonathan Ongbefore adoption34c83d7
lines 71–74why, one step back71 })72 })73 })74})