Skip to content

Commit e5fc53f

Browse files
committed
add tests
1 parent 7303ea9 commit e5fc53f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

tests/unit/Search/SearchQueryUtilsTest.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ describe('SearchQueryUtils', () => {
188188
);
189189
expect(result).not.toMatch(CONST.VALIDATE_FOR_HTML_TAG_REGEX);
190190
});
191+
192+
test('with withdrawn filter', () => {
193+
const filterValues: Partial<SearchAdvancedFiltersForm> = {
194+
type: 'expense',
195+
status: CONST.SEARCH.STATUS.EXPENSE.ALL,
196+
withdrawnOn: CONST.SEARCH.DATE_PRESETS.LAST_MONTH,
197+
};
198+
199+
const result = buildQueryStringFromFilterFormValues(filterValues);
200+
201+
expect(result).toEqual('sortBy:date sortOrder:desc type:expense withdrawn:last-month');
202+
});
191203
});
192204

193205
describe('buildFilterFormValuesFromQuery', () => {

tests/unit/SearchParserTest.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,20 @@ const keywordTests = [
588588
},
589589
},
590590
},
591+
{
592+
query: 'type:expense withdrawn:last-month',
593+
expected: {
594+
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
595+
status: CONST.SEARCH.STATUS.EXPENSE.ALL,
596+
sortBy: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE,
597+
sortOrder: CONST.SEARCH.SORT_ORDER.DESC,
598+
filters: {
599+
operator: CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO,
600+
left: CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWN,
601+
right: CONST.SEARCH.DATE_PRESETS.LAST_MONTH,
602+
},
603+
},
604+
},
591605
];
592606

593607
describe('search parser', () => {

0 commit comments

Comments
 (0)