e8f79d43f9
closes #517 add index test for Application add app.toJSON test add test for app.inspect() add tests for app.use() add tests for app.onerror() add tests for app.respond() add tests for app.context() add tests for app.request() add tests for app.response refactor for non-existence of test/app...js no need for *.js use helpers/ dir for non-tests
32 lines
891 B
JavaScript
32 lines
891 B
JavaScript
|
|
'use strict';
|
|
|
|
const request = require('../helpers/context').request;
|
|
|
|
describe('req.ip', function(){
|
|
describe('with req.ips present', function(){
|
|
it('should return req.ips[0]', function(){
|
|
const req = request();
|
|
req.app.proxy = true;
|
|
req.header['x-forwarded-for'] = '127.0.0.1';
|
|
req.socket.remoteAddress = '127.0.0.2';
|
|
req.ip.should.equal('127.0.0.1');
|
|
})
|
|
})
|
|
|
|
describe('with no req.ips present', function(){
|
|
it('should return req.socket.remoteAddress', function(){
|
|
const req = request();
|
|
req.socket.remoteAddress = '127.0.0.2';
|
|
req.ip.should.equal('127.0.0.2');
|
|
})
|
|
|
|
describe('with req.socket.remoteAddress not present', function(){
|
|
it('should return an empty string', function(){
|
|
const req = request();
|
|
req.socket.remoteAddress = null;
|
|
req.ip.should.equal('');
|
|
})
|
|
})
|
|
})
|
|
})
|