File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -608,12 +608,15 @@ Index.prototype.clearIndex = function(callback) {
608
608
* @param opts.advanced get more settings like nbShards (useful for Enterprise)
609
609
* @param callback (optional) the result callback called with two arguments
610
610
* error: null or Error('message')
611
- * content: the settings object or the error message if a failure occured
611
+ * content: the settings object or the error message if a failure occurred
612
612
*/
613
613
Index . prototype . getSettings = function ( opts , callback ) {
614
- if ( arguments . length === 1 || typeof opts === 'function' ) {
615
- callback = opts ;
616
- opts = { } ;
614
+ if ( arguments . length < 2 ) {
615
+ if ( typeof opts === 'function' ) {
616
+ callback = opts ;
617
+ opts = { } ;
618
+ }
619
+ opts = opts || { } ;
617
620
}
618
621
619
622
var indexName = encodeURIComponent ( this . indexName ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ _.bindAll(index);
48
48
test ( 'index.clearIndex' , clearIndex ) ;
49
49
if ( canPUT ) {
50
50
test ( 'index.setSettings' , setSettings ) ;
51
+ test ( 'index.getSettings' , getSettings ) ;
51
52
}
52
53
test ( 'index.saveObjects' , saveObjects ) ;
53
54
if ( canPUT ) {
@@ -137,6 +138,20 @@ function setSettings(t) {
137
138
. then ( noop , _ . bind ( t . error , t ) ) ;
138
139
}
139
140
141
+ function getSettings ( t ) {
142
+ t . plan ( 2 ) ;
143
+
144
+ index
145
+ . setSettings ( { attributesForFaceting : [ 'searchable(category)' ] } )
146
+ . then ( function ( ) { return index . getSettings ( { advanced : 1 } ) ; } )
147
+ . then ( get ( 'attributesForFaceting' ) )
148
+ . then ( _ . partialRight ( t . deepEqual , [ 'searchable(category)' ] , 'Settings were get (advanced)' ) )
149
+ . then ( index . getSettings )
150
+ . then ( get ( 'attributesForFaceting' ) )
151
+ . then ( _ . partialRight ( t . deepEqual , [ 'searchable(category)' ] , 'Settings were get' ) )
152
+ . then ( noop , _ . bind ( t . error , t ) ) ;
153
+ }
154
+
140
155
function searchForFacetValues ( t ) {
141
156
t . plan ( 1 ) ;
142
157
You can’t perform that action at this time.
0 commit comments