2023-06-20 00:43:36 +05:30
|
|
|
import {
|
|
|
|
FILTERED_SEARCH_TOKEN_CATEGORY,
|
|
|
|
FILTERED_SEARCH_TOKEN_STATUS,
|
|
|
|
} from '~/admin/abuse_reports/constants';
|
|
|
|
import { buildFilteredSearchCategoryToken, isValidStatus } from '~/admin/abuse_reports/utils';
|
2023-05-27 22:25:52 +05:30
|
|
|
|
|
|
|
describe('buildFilteredSearchCategoryToken', () => {
|
|
|
|
it('adds correctly formatted options to FILTERED_SEARCH_TOKEN_CATEGORY', () => {
|
|
|
|
const categories = ['tuxedo', 'tabby'];
|
|
|
|
|
|
|
|
expect(buildFilteredSearchCategoryToken(categories)).toMatchObject({
|
|
|
|
...FILTERED_SEARCH_TOKEN_CATEGORY,
|
|
|
|
options: categories.map((c) => ({ value: c, title: c })),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
describe('isValidStatus', () => {
|
|
|
|
const validStatuses = FILTERED_SEARCH_TOKEN_STATUS.options.map((o) => o.value);
|
|
|
|
|
|
|
|
it.each(validStatuses)(
|
|
|
|
'returns true when status is an option value of FILTERED_SEARCH_TOKEN_STATUS',
|
|
|
|
(status) => {
|
|
|
|
expect(isValidStatus(status)).toBe(true);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
it('return false when status is not an option value of FILTERED_SEARCH_TOKEN_STATUS', () => {
|
|
|
|
expect(isValidStatus('invalid')).toBe(false);
|
|
|
|
});
|
|
|
|
});
|