1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-11-27 22:38:10 +02:00

Fixing benchmark (Adding new search cases after advanced search is ready)

This commit is contained in:
Patrik J. Braun
2021-05-10 13:03:22 +02:00
parent ab7a61f46c
commit a75a28f5c4
4 changed files with 140 additions and 42 deletions

View File

@@ -19,33 +19,33 @@ import {
} from '../../../src/common/entities/SearchQueryDTO';
import {QueryKeywords, SearchQueryParser} from '../../../src/common/SearchQueryParser';
const queryKeywords: QueryKeywords = {
NSomeOf: '-of',
and: 'and',
caption: 'caption',
directory: 'directory',
file_name: 'file-name',
from: 'from',
keyword: 'keyword',
landscape: 'landscape',
maxRating: 'max-rating',
maxResolution: 'max-resolution',
minRating: 'min-rating',
minResolution: 'min-resolution',
or: 'or',
orientation: 'orientation',
person: 'person',
portrait: 'portrait',
position: 'position',
someOf: 'some-of',
to: 'to',
kmFrom: 'km-from'
};
describe('SearchQueryParser', () => {
const keywords: QueryKeywords = {
NSomeOf: '-of',
and: 'and',
caption: 'caption',
directory: 'directory',
file_name: 'file-name',
from: 'from',
keyword: 'keyword',
landscape: 'landscape',
maxRating: 'max-rating',
maxResolution: 'max-resolution',
minRating: 'min-rating',
minResolution: 'min-resolution',
or: 'or',
orientation: 'orientation',
person: 'person',
portrait: 'portrait',
position: 'position',
someOf: 'some-of',
to: 'to',
kmFrom: 'km-from'
};
const check = (query: SearchQueryDTO) => {
const parser = new SearchQueryParser(keywords);
const parser = new SearchQueryParser(queryKeywords);
expect(parser.parse(parser.stringify(query))).to.deep.equals(query, parser.stringify(query));
};
@@ -72,14 +72,14 @@ describe('SearchQueryParser', () => {
check({type: SearchQueryTypes.to_date, value: (new Date(2020, 1, 20)).getTime()} as ToDateSearch);
check({type: SearchQueryTypes.to_date, value: (new Date(2020, 1, 1)).getTime()} as ToDateSearch);
const parser = new SearchQueryParser(keywords);
const parser = new SearchQueryParser(queryKeywords);
// test if date gets simplified on 1st of Jan.
let query: RangeSearch = {type: SearchQueryTypes.to_date, value: (new Date(2020, 0, 1)).getTime()} as ToDateSearch;
expect(parser.parse(keywords.to + ':' + (new Date(query.value)).getFullYear()))
expect(parser.parse(queryKeywords.to + ':' + (new Date(query.value)).getFullYear()))
.to.deep.equals(query, parser.stringify(query));
query = ({type: SearchQueryTypes.from_date, value: (new Date(2020, 0, 1)).getTime()} as FromDateSearch);
expect(parser.parse(keywords.from + ':' + (new Date(query.value)).getFullYear()))
expect(parser.parse(queryKeywords.from + ':' + (new Date(query.value)).getFullYear()))
.to.deep.equals(query, parser.stringify(query));
});