debian-mirror-gitlab/spec/frontend/admin/abuse_reports/utils_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1 KiB
JavaScript
Raw Normal View History

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);
});
});