import { matchesAnyTag } from '../src/utils';
describe('hasMatchingTag', () => {
test('should return true when there is a common tag', () => {
const tags = ['apple π', 'banana π', 'orange π'];
const filteringTags = ['banana π', 'grape π'];
expect(matchesAnyTag(tags, filteringTags)).toBeTruthy();
});
test('should return false when there are no common tags', () => {
const tags = ['apple π', 'banana π', 'orange π'];
const filteringTags = ['grape π', 'kiwi π₯'];
expect(matchesAnyTag(tags, filteringTags)).toBeFalsy();
});
test('should return false when tags array is empty (i.e. deactivated tool)', () => {
const tags: string[] = [];
const filteringTags = ['apple π', 'banana π'];
expect(matchesAnyTag(tags, filteringTags)).toBeFalsy();
});
test('should return true when no filtering tag are provided (i.e. all tools are activated)', () => {
const tags = ['apple π', 'banana π', 'orange π'];
const filteringTags: string[] = [];
expect(matchesAnyTag(tags, filteringTags)).toBeTruthy();
});
test('should match even if casing if different', () => {
const tags = ['banana π'];
const filteringTags = ['BANANA π'];
expect(matchesAnyTag(tags, filteringTags)).toBeTruthy();
});
test('should return true when multiple common tags exist', () => {
const tags = ['apple π', 'banana π', 'orange π'];
const filteringTags = ['banana π', 'orange π', 'grape π'];
expect(matchesAnyTag(tags, filteringTags)).toBeTruthy();
});
});