Fixed failing tests

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2022-06-18 12:29:54 -05:00
committed by Fredrik Adelöw
parent d43228a183
commit b69dd94766
2 changed files with 44 additions and 6 deletions
@@ -26,7 +26,7 @@ import { PgSearchEngineIndexer } from './PgSearchEngineIndexer';
const highlightOptions: PgSearchHighlightConfig = {
preTag: '<tag>',
postTag: '</tag>',
useHighlight: false,
useHighlight: true,
maxWords: 35,
minWords: 15,
shortWord: 3,
@@ -35,6 +35,8 @@ const highlightOptions: PgSearchHighlightConfig = {
fragmentDelimiter: ' ... ',
};
jest.mock('uuid', () => ({ v4: () => 'tag' }));
jest.mock('./PgSearchEngineIndexer', () => ({
PgSearchEngineIndexer: jest
.fn()
@@ -71,10 +73,13 @@ describe('PgSearchEngine', () => {
filters: {},
});
expect(translatorSpy).toHaveBeenCalledWith({
term: 'testTerm',
filters: {},
});
expect(translatorSpy).toHaveBeenCalledWith(
{
term: 'testTerm',
filters: {},
},
highlightOptions,
);
});
it('should pass page cursor', async () => {
@@ -205,6 +210,16 @@ describe('PgSearchEngine', () => {
},
type: 'my-type',
rank: 1,
highlight: {
preTag: '<tag>',
postTag: '</tag>',
fields: {
title: 'Hello World',
text: 'Lorem Ipsum',
location: 'location-1',
path: '',
},
},
},
],
nextPageCursor: undefined,
@@ -214,6 +229,7 @@ describe('PgSearchEngine', () => {
pgTerm: '("Hello" | "Hello":*)&("World" | "World":*)',
offset: 0,
limit: 26,
options: highlightOptions,
});
});
@@ -252,6 +268,16 @@ describe('PgSearchEngine', () => {
},
type: 'my-type',
rank: i + 1,
highlight: {
preTag: '<tag>',
postTag: '</tag>',
fields: {
title: 'Hello World',
text: 'Lorem Ipsum',
location: 'location-1',
path: '',
},
},
})),
nextPageCursor: 'MQ==',
});
@@ -260,6 +286,7 @@ describe('PgSearchEngine', () => {
pgTerm: '("Hello" | "Hello":*)&("World" | "World":*)',
offset: 0,
limit: 26,
options: highlightOptions,
});
});
@@ -300,6 +327,16 @@ describe('PgSearchEngine', () => {
},
type: 'my-type',
rank: i + 1,
highlight: {
preTag: '<tag>',
postTag: '</tag>',
fields: {
title: 'Hello World',
text: 'Lorem Ipsum',
location: 'location-1',
path: '',
},
},
}))
.slice(25),
previousPageCursor: 'MA==',
@@ -309,6 +346,7 @@ describe('PgSearchEngine', () => {
pgTerm: '("Hello" | "Hello":*)&("World" | "World":*)',
offset: 25,
limit: 26,
options: highlightOptions,
});
});
});
@@ -46,7 +46,7 @@ export class PgSearchEngine implements SearchEngine {
this.highlightOptions = {
preTag: `<${uuidTag}>`,
postTag: `</${uuidTag}>`,
useHighlight: false,
useHighlight: true,
maxWords: 35,
minWords: 15,
shortWord: 3,