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:
Spencer Alger
2013-11-05 09:57:56 -07:00
parent 4273ffc2c7
commit 7e6fa479ad
34 changed files with 58054 additions and 1008 deletions

View 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'
]);
});
});
});

View File

@ -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();
});
});
});
});