Added the browser based test suite, have it running automatically via PhantomJS with grunt, all tests are passing except one, which requires PhantomJS send a body with a DELETE request
This commit is contained in:
39
test/unit/http.connection.test.js
Normal file
39
test/unit/http.connection.test.js
Normal file
@ -0,0 +1,39 @@
|
||||
describe('Http Connector', function () {
|
||||
|
||||
var Host = require('../../src/lib/host');
|
||||
var HttpConnection = require('../../src/lib/connectors/http');
|
||||
var host = new Host('http://someesserver.com:9205/prefix');
|
||||
var con;
|
||||
|
||||
describe('#makeReqParams', function () {
|
||||
|
||||
before(function () {
|
||||
con = new HttpConnection(host, {});
|
||||
});
|
||||
|
||||
it('creates the request params property', function () {
|
||||
var reqParams = con.makeReqParams({
|
||||
method: 'GET',
|
||||
path: '/_cluster/nodes/stats',
|
||||
query: {
|
||||
jvm: true
|
||||
}
|
||||
});
|
||||
|
||||
reqParams.should.include({
|
||||
method: 'GET',
|
||||
protocol: 'http:',
|
||||
auth: '',
|
||||
hostname: 'someesserver.com',
|
||||
port: '9205',
|
||||
path: '/prefix/_cluster/nodes/stats?jvm=true'
|
||||
});
|
||||
|
||||
Object.keys(reqParams).should.not.include([
|
||||
'host', 'pathname', 'query'
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@ -1,23 +0,0 @@
|
||||
require('mocha-as-promised')();
|
||||
|
||||
var NodeHttp = require('../../src/lib/transports/node_http')
|
||||
, expect = require('expect.js');
|
||||
|
||||
describe('NodeHttp Transport', function () {
|
||||
|
||||
var transport = new NodeHttp(['localhost:9200']);
|
||||
|
||||
describe('#send', function () {
|
||||
it('should ignore host in url', function (done) {
|
||||
transport.request({
|
||||
url: 'http://google.com/',
|
||||
method: 'get',
|
||||
body: null
|
||||
}).then(function (resp) {
|
||||
expect(resp.version.number).to.be.a('string');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user