Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 34c83d7 point at it.

3.4.7Jonathan Ongbefore adoption34c83d7

lines 1–2why, one step back
1
2var express = require('../')

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 3why, one step back
3 , request = require('supertest');

3.4.7Jonathan Ongbefore adoption34c83d7

lines 4–17why, one step back
4
5describe('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 back
18 .expect(200)
19 .end(function(err, res){20 done(err);

3.4.7Jonathan Ongbefore adoption34c83d7

lines 21–22why, one step back
21 })
22 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 23why, one step back
23

3.4.7Jonathan Ongbefore adoption34c83d7

lines 24–34why, one step back
24 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 back
35 .expect(200)
36 .end(function(err, res){37 done(err);

3.4.7Jonathan Ongbefore adoption34c83d7

lines 38–39why, one step back
38 })
39 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 40why, one step back
40

3.4.7Jonathan Ongbefore adoption34c83d7

lines 41–51why, one step back
41 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 back
52 .expect(200)
53 .end(function(err, res){54 done(err);

3.4.7Jonathan Ongbefore adoption34c83d7

lines 55–56why, one step back
55 })
56 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 57why, one step back
57

3.4.7Jonathan Ongbefore adoption34c83d7

lines 58–67why, one step back
58 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 back
68 .expect(200)
69 .end(function(err, res){70 done(err);

3.4.7Jonathan Ongbefore adoption34c83d7

lines 71–74why, one step back
71 })
72 })73 })74})