koa-lite/test/request/subdomains.js

22 lines
521 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
'use strict';
const request = require('../helpers/context').request;
2014-07-06 08:43:14 +00:00
describe('req.subdomains', function(){
it('should return subdomain array', function(){
const req = request();
2014-07-06 08:43:14 +00:00
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']);
})
describe('with no host present', function(){
const req = request();
2014-07-06 08:43:14 +00:00
req.subdomains.should.eql([]);
})
})