Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-Melnyshyn committed Jan 5, 2024
1 parent ed742ce commit c7ddbff
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
10 changes: 5 additions & 5 deletions lib/SearchAndSort/advancedSearchQueryToRows.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ADVANCED_SEARCH_MATCH_OPTIONS,
ADVANCED_SEARCH_DEFAULT_SEARCH_OPTION,
} from '@folio/stripes-components';
MATCH_OPTIONS,
DEFAULT_SEARCH_OPTION,
} from '@folio/stripes-components/lib/AdvancedSearch';

const advancedSearchQueryToRows = (queryValue) => {
if (!queryValue) {
Expand Down Expand Up @@ -34,8 +34,8 @@ const advancedSearchQueryToRows = (queryValue) => {
return {
query: value,
bool,
searchOption: option || ADVANCED_SEARCH_DEFAULT_SEARCH_OPTION,
match: _match || ADVANCED_SEARCH_MATCH_OPTIONS.CONTAINS_ALL,
searchOption: option || DEFAULT_SEARCH_OPTION,
match: _match || MATCH_OPTIONS.CONTAINS_ALL,
};
});
};
Expand Down
108 changes: 54 additions & 54 deletions lib/SearchAndSort/tests/advancedSearchQueryToRows-test.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import React from 'react';
import {
describe,
it,
} from 'mocha';
import { expect } from 'chai';

import advancedSearchQueryToRows from '../advancedSearchQueryToRows';

describe('advancedSearchQueryToRows', () => {
describe('when query contains multiple rows', () => {
it('should parse query correctly', () => {
const query = 'keyword exactPhrase value1 or keyword exactPhrase value2';

expect(advancedSearchQueryToRows(query)).to.have.deep.members([{
query: 'value1',
bool: '',
searchOption: 'keyword',
match: 'exactPhrase',
}, {
query: 'value2',
bool: 'or',
searchOption: 'keyword',
match: 'exactPhrase',
}]);
});
});

describe('when query contains match option as part of value', () => {
it('should parse query correctly', () => {
const query = 'keyword containsAny containsAny1';

expect(advancedSearchQueryToRows(query)).to.deep.include({
query: 'containsAny1',
bool: '',
searchOption: 'keyword',
match: 'containsAny',
});
});
});

describe('when query without match and search option', () => {
it('should use default value for match and search option', () => {
const query = 'test';

expect(advancedSearchQueryToRows(query)).to.deep.include({
query,
bool: '',
searchOption: 'keyword',
match: 'containsAll',
});
});
});
});
import React from 'react';
import {
describe,
it,
} from 'mocha';
import { expect } from 'chai';

import advancedSearchQueryToRows from '../advancedSearchQueryToRows';

describe('advancedSearchQueryToRows', () => {
describe('when query contains multiple rows', () => {
it('should parse query correctly', () => {
const query = 'keyword exactPhrase value1 or keyword exactPhrase value2';

expect(advancedSearchQueryToRows(query)).to.have.deep.members([{
query: 'value1',
bool: '',
searchOption: 'keyword',
match: 'exactPhrase',
}, {
query: 'value2',
bool: 'or',
searchOption: 'keyword',
match: 'exactPhrase',
}]);
});
});

describe('when query contains match option as part of value', () => {
it('should parse query correctly', () => {
const query = 'keyword containsAny containsAny1';

expect(advancedSearchQueryToRows(query)).to.deep.include({
query: 'containsAny1',
bool: '',
searchOption: 'keyword',
match: 'containsAny',
});
});
});

describe('when query without match and search option', () => {
it('should use default value for match and search option', () => {
const query = 'test';

expect(advancedSearchQueryToRows(query)).to.deep.include({
query,
bool: '',
searchOption: 'keyword',
match: 'containsAll',
});
});
});
});

0 comments on commit c7ddbff

Please sign in to comment.