reorganized tests. now allow for single string sub-host declaration

This commit is contained in:
mgudesblatart
2018-03-01 16:45:52 -05:00
parent 0eb59d42f9
commit 09d9affa92
6 changed files with 218 additions and 69 deletions
-37
View File
@@ -67,41 +67,4 @@ test('should respond to request', function(done) {
done();
});
});
});
test('set up localtunnel client (sub-host)', function (done) {
var opt = {
host: 'http://nested.sub.host:' + lt_server_port,
subdomain: 'txy-z'
};
localtunnel(test._fake_port, opt, function (err, tunnel) {
assert.ifError(err);
var url = tunnel.url;
assert.ok(new RegExp('^http:\/\/.*nested.sub.host:' + lt_server_port + '$').test(url));
test._fake_url = url;
done(err);
});
});
test('should respond to request (sub-host)', function (done) {
var hostname = url.parse(test._fake_url).hostname;
var opt = {
host: 'nested.sub.host',
port: lt_server_port,
headers: {
host: hostname + '.tld'
}
};
http.get(opt, function (res) {
var body = '';
res.setEncoding('utf-8');
res.on('data', function (chunk) {
body += chunk;
});
res.on('end', function () {
assert.equal(body, 'hello world!');
done();
});
});
});