mirror of
https://github.com/zebrajr/express.git
synced 2026-01-15 12:15:27 +00:00
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
|
|
var express = require('../')
|
|
, request = require('./support/http');
|
|
|
|
describe('req', function(){
|
|
describe('.xhr', function(){
|
|
it('should return true when X-Requested-With is xmlhttprequest', function(done){
|
|
var app = express();
|
|
|
|
app.use(function(req, res){
|
|
req.xhr.should.be.true;
|
|
res.end();
|
|
});
|
|
|
|
request(app)
|
|
.get('/')
|
|
.set('X-Requested-With', 'xmlhttprequest')
|
|
.end(function(res){
|
|
done();
|
|
})
|
|
})
|
|
|
|
it('should return false otherwise', function(done){
|
|
var app = express();
|
|
|
|
app.use(function(req, res){
|
|
req.xhr.should.be.false;
|
|
res.end();
|
|
});
|
|
|
|
request(app)
|
|
.get('/')
|
|
.set('X-Requested-With', 'blahblah')
|
|
.end(function(res){
|
|
done();
|
|
})
|
|
})
|
|
|
|
it('should return false when not present', function(done){
|
|
var app = express();
|
|
|
|
app.use(function(req, res){
|
|
req.xhr.should.be.false;
|
|
res.end();
|
|
});
|
|
|
|
request(app)
|
|
.get('/')
|
|
.end(function(res){
|
|
done();
|
|
})
|
|
})
|
|
})
|
|
})
|