Skip to content

Commit

Permalink
fix: Update facet query option size to be 10 (#40)
Browse files Browse the repository at this point in the history
* fix: Update facet query option size to be 10

* chore: version upgrade and tests
  • Loading branch information
adilansari authored Jun 30, 2022
1 parent 59607c8 commit 30dd5d2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tigrisdata/core",
"version": "1.0.0-alpha.9",
"version": "1.0.0-alpha.10",
"description": "Tigris client for Typescript",
"author": "Tigris Data (https://www.tigrisdata.com/)",
"contributors": [
Expand All @@ -12,7 +12,11 @@
{
"name": "Jigar Joshi",
"url": "https://www.tigrisdata.com/"
}
},
{
"name": "Adil Ansari",
"url": "https://www.tigrisdata.com/"
}
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions src/__tests__/search/search.utility.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Utility} from "../../search/utility";
import {FacetQueryFieldType} from "../../search/types";

describe('Search utility', () => {
it('generates default facet query options', () => {
const generatedOptions = Utility.createFacetQueryOptions();
expect(generatedOptions.size).toBe(10);
expect(generatedOptions.type).toBe(FacetQueryFieldType.VALUE);
});

it('backfills missing facet query options', () =>{
const generatedOptions = Utility.createFacetQueryOptions({
size: 55
});
expect(generatedOptions.size).toBe(55);
expect(generatedOptions.type).toBe(FacetQueryFieldType.VALUE);
});

it('generates default search request options', () => {
const generatedOptions = Utility.createSearchRequestOptions();
expect(generatedOptions.page).toBe(1);
expect(generatedOptions.perPage).toBe(10);
});

it('backfills missing search request options', () => {
const generatedOptions = Utility.createSearchRequestOptions({
perPage: 129
});
expect(generatedOptions.page).toBe(1);
expect(generatedOptions.perPage).toBe(129);
});
});
2 changes: 1 addition & 1 deletion src/search/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FacetQueryFieldType, FacetQueryOptions, SearchRequestOptions} from "./ty
export const Utility = {

createFacetQueryOptions(options?: Partial<FacetQueryOptions>): FacetQueryOptions {
const defaults = {size: 1, type: FacetQueryFieldType.VALUE};
const defaults = {size: 10, type: FacetQueryFieldType.VALUE};
return {...defaults, ...options};
},

Expand Down

0 comments on commit 30dd5d2

Please sign in to comment.