This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #84 : Add a more friendly way to update a single parameter on Sea…
…rchParameters
- Loading branch information
Alexandre Stanislawski
committed
Jun 2, 2015
1 parent
47a2073
commit 8895e5f
Showing
3 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use strict"; | ||
var test = require( "tape" ); | ||
//var _ = require( "lodash" ); | ||
var SearchParameters = require( "../../src/SearchParameters" ); | ||
|
||
test( "setqueryparameter should update existing parameter", function( t ) { | ||
var sp = new SearchParameters( { | ||
facets : ["facet"] | ||
} ); | ||
|
||
var newValue = []; | ||
var newsp = sp.setQueryParameter( "facets", newValue ); | ||
|
||
t.equal( newsp.facets, newValue, "update of an existing parameter" ); | ||
|
||
t.end(); | ||
} ); | ||
|
||
test( "setqueryparameter should add non-existing parameter", function( t ) { | ||
var sp = new SearchParameters( { | ||
facets : ["facet"] | ||
} ); | ||
|
||
var newValue = [ "attributesToHighlight" ]; | ||
var newsp = sp.setQueryParameter( "attributesToHighlight", newValue ); | ||
|
||
t.equal( newsp.attributesToHighlight, newValue, "add new parameter" ); | ||
|
||
t.end(); | ||
} ); | ||
|
||
test( "setQueryParameter should not create a new instance if the update is non effective", function( t ) { | ||
var sp = new SearchParameters( { | ||
facets : ["facet"], | ||
maxValuesPerFacet : 10 | ||
} ); | ||
|
||
var newValue = 10; | ||
var newsp = sp.setQueryParameter( "maxValuesPerFacet", newValue ); | ||
|
||
t.equal( newsp, sp, "No change should result in the same instance" ); | ||
|
||
t.end(); | ||
} ); | ||
|
||
test( "setQueryParameter should not create a new instance if the parameter is unknown", function( t ) { | ||
var sp = new SearchParameters( { | ||
facets : ["facet"] | ||
} ); | ||
|
||
var newValue = [ "attributesToHighlight" ]; | ||
var newsp = sp.setQueryParameter( "unknown", newValue ); | ||
|
||
t.equal( newsp, sp, "Unknown parameter should return the same instance" ); | ||
|
||
t.end(); | ||
} ); |
File renamed without changes.