koa-lite/test/request/ip.js
broucz 4b1a1da652 test: switch all functions to arrow functions
closes #553

Update test: application -> use() should throw if not a function

Fix lint

Use arrow function

Refactor test using arrow function

Remove non mandatory brackets

fix for merge

Fix: missing refactor after merge

Use arrow function for old generator
2015-11-02 11:22:05 -08:00

32 lines
870 B
JavaScript

'use strict';
const request = require('../helpers/context').request;
describe('req.ip', () => {
describe('with req.ips present', () => {
it('should return req.ips[0]', () => {
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', () => {
it('should return req.socket.remoteAddress', () => {
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', () => {
it('should return an empty string', () => {
const req = request();
req.socket.remoteAddress = null;
req.ip.should.equal('');
});
});
});
});