elasticsearch
Advanced tools
Comparing version 1.5.7 to 1.5.8
@@ -10,3 +10,3 @@ { | ||
"homepage": "http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/index.html", | ||
"version": "1.5.7", | ||
"version": "1.5.8", | ||
"browser": { | ||
@@ -13,0 +13,0 @@ "./src/lib/connectors/index.js": "./src/lib/connectors/browser_index.js", |
@@ -39,3 +39,3 @@ # elasticsearch.js | ||
### Download | ||
- v1.5.7: [zip](https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-1.5.7.zip), [tar.gz](https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-1.5.7.tar.gz) | ||
- v1.5.8: [zip](https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-1.5.8.zip), [tar.gz](https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-1.5.8.tar.gz) | ||
@@ -42,0 +42,0 @@ ## Docs |
@@ -28,3 +28,3 @@ /** | ||
try { | ||
return exec(this.transport, spec, params, cb); | ||
return exec(this.transport, spec, _.clone(params), cb); | ||
} catch (e) { | ||
@@ -31,0 +31,0 @@ if (typeof cb === 'function') { |
@@ -64,2 +64,18 @@ var ca = require('../../../src/lib/client_action'); | ||
// used to check that params are not clobbered | ||
var params = (function () { | ||
var _stash = {}; | ||
afterEach(function () { _stash = {}; }); | ||
var make = function (params) { | ||
_stash.orig = params; | ||
_stash.copy = _.clone(params); | ||
return params; | ||
}; | ||
make.check = function () { | ||
expect(_stash.orig).to.eql(_stash.copy); | ||
}; | ||
return make; | ||
}()); | ||
describe('argument juggling', function () { | ||
@@ -399,2 +415,3 @@ it('creates an empty param set when no params are sent', function (done) { | ||
}); | ||
it('rejects objects', function (done) { | ||
@@ -408,2 +425,3 @@ action({ | ||
}); | ||
it('rejects arrays', function (done) { | ||
@@ -417,2 +435,3 @@ action({ | ||
}); | ||
it('rejects regexp', function (done) { | ||
@@ -470,2 +489,3 @@ action({ | ||
}); | ||
it('rejects objects', function (done) { | ||
@@ -479,2 +499,3 @@ action({ | ||
}); | ||
it('rejects arrays', function (done) { | ||
@@ -488,2 +509,3 @@ action({ | ||
}); | ||
it('rejects regexp', function (done) { | ||
@@ -541,2 +563,3 @@ action({ | ||
}); | ||
it('rejects arrays', function (done) { | ||
@@ -550,2 +573,3 @@ action({ | ||
}); | ||
it('rejects regexp', function (done) { | ||
@@ -679,3 +703,3 @@ action({ | ||
var action = makeClientAction({ | ||
var action = makeClientAction({ | ||
urls: [ | ||
@@ -708,6 +732,7 @@ { | ||
it('rejects a url if it required params that are not present', function (done) { | ||
action({ | ||
action(params({ | ||
type: ['type1', 'type2'] | ||
}, function (err, params) { | ||
}), function (err, resp) { | ||
expect(err).to.be.a(TypeError); | ||
params.check(); | ||
done(); | ||
@@ -718,8 +743,9 @@ }); | ||
it('uses the default value for optional params', function (done) { | ||
action({ | ||
action(params({ | ||
index: 'index1', | ||
id: '1' | ||
}, function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.path).to.be('/index1/_all/1/'); | ||
expect(resp.path).to.be('/index1/_all/1/'); | ||
params.check(); | ||
done(); | ||
@@ -730,3 +756,3 @@ }); | ||
it('casts both optional and required args', function (done) { | ||
action({ | ||
action(params({ | ||
index: ['index1', 'index2'], | ||
@@ -736,5 +762,6 @@ id: '123', | ||
thing: 'poo' | ||
}, function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.path).to.be('/index1%2Cindex2/_all%2C-pizza/123/poo'); | ||
expect(resp.path).to.be('/index1%2Cindex2/_all%2C-pizza/123/poo'); | ||
params.check(); | ||
done(); | ||
@@ -755,12 +782,12 @@ }); | ||
it('collects all of the params into params.query', function (done) { | ||
action({ | ||
action(params({ | ||
a: 'pizza', | ||
b: '1M' | ||
}, | ||
function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.query).to.eql({ | ||
expect(resp.query).to.eql({ | ||
a: 'pizza', | ||
b: '1M' | ||
}); | ||
params.check(); | ||
done(); | ||
@@ -771,10 +798,9 @@ }); | ||
it('includes extra params', function (done) { | ||
action({ | ||
action(params({ | ||
a: 'pizza', | ||
b: '3w', | ||
c: 'popular', | ||
}, | ||
function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.query).to.eql({ | ||
expect(resp.query).to.eql({ | ||
a: 'pizza', | ||
@@ -784,2 +810,3 @@ b: '3w', | ||
}); | ||
params.check(); | ||
done(); | ||
@@ -790,11 +817,11 @@ }); | ||
it('excludes default values', function (done) { | ||
action({ | ||
action(params({ | ||
a: 'pizza', | ||
b: '15m', | ||
}, | ||
function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.query).to.eql({ | ||
expect(resp.query).to.eql({ | ||
a: 'pizza' | ||
}); | ||
params.check(); | ||
done(); | ||
@@ -805,3 +832,3 @@ }); | ||
it('does not include non-query param keys', function (done) { | ||
action({ | ||
action(params({ | ||
a: 'pizza', | ||
@@ -814,6 +841,5 @@ b: '3w', | ||
ignore: 201 | ||
}, | ||
function (err, params) { | ||
}), function (err, resp) { | ||
if (err) { throw err; } | ||
expect(params.query).to.eql({ | ||
expect(resp.query).to.eql({ | ||
a: 'pizza', | ||
@@ -823,2 +849,3 @@ b: '3w', | ||
}); | ||
params.check(); | ||
done(); | ||
@@ -829,12 +856,33 @@ }); | ||
it('enforces required params', function (done) { | ||
action({ | ||
action(params({ | ||
b: '3w' | ||
}, | ||
function (err, params) { | ||
}), function (err, resp) { | ||
expect(err).to.be.a(TypeError); | ||
params.check(); | ||
done(); | ||
}); | ||
}); | ||
it('does not modify the incoming params object', function () { | ||
var action = makeClientAction({ | ||
url: { | ||
req: { | ||
index: { type: 'string' } | ||
}, | ||
fmt: '/<%= index %>' | ||
} | ||
}); | ||
action(params({ | ||
index: 'index' | ||
}), function (err, resp) { | ||
expect(resp).to.eql({ | ||
method: 'GET', | ||
path: '/index', | ||
query: {} | ||
}); | ||
params.check(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21619887
78494