koa-lite/test/request/subdomains.js

28 lines
677 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
'use strict';
2014-07-06 08:43:14 +00:00
var request = require('../context').request;
describe('req.subdomains', function(){
it('should return subdomain array', function(){
var req = request();
req.header.host = 'tobi.ferrets.example.com';
req.app.subdomainOffset = 2;
req.subdomains.should.eql(['ferrets', 'tobi']);
req.app.subdomainOffset = 3;
req.subdomains.should.eql(['tobi']);
})
it('should work with no host present', function(){
2014-07-06 08:43:14 +00:00
var req = request();
req.subdomains.should.eql([]);
})
it('should check if the host is an ip address', function(){
var req = request();
req.header.host = '127.0.0.1';
req.subdomains.should.eql([]);
});
2014-07-06 08:43:14 +00:00
})