mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
find-unique tool and testcases the updated index file
This commit is contained in:
47
src/pages/list/find-unique/find-unique.service.test.ts
Normal file
47
src/pages/list/find-unique/find-unique.service.test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
|
||||
import { TopItemsList } from './service';
|
||||
|
||||
describe('TopItemsList Function', () => {
|
||||
test('should return unique items ignoring case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, true, true, false, true);
|
||||
expect(result).toBe('orange');
|
||||
});
|
||||
|
||||
test('should return unique items considering case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, true, true, true, true);
|
||||
expect(result).toBe('banana\nApple\norange\nBanana');
|
||||
});
|
||||
|
||||
test('should return all unique items ignoring case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, true, true, false, false);
|
||||
expect(result).toBe('apple\nbanana\norange');
|
||||
});
|
||||
|
||||
test('should return all unique items considering case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, true, true, true, false);
|
||||
expect(result).toBe('apple\nbanana\nApple\norange\nBanana');
|
||||
});
|
||||
|
||||
test('should handle empty items deletion', () => {
|
||||
const input = 'apple,,banana, ,orange';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, true, true, false, false);
|
||||
expect(result).toBe('apple\nbanana\norange');
|
||||
});
|
||||
|
||||
test('should handle trimming items', () => {
|
||||
const input = ' apple , banana , orange ';
|
||||
const result = TopItemsList('symbol', ',', '\n', input, false, false, false, false);
|
||||
expect(result).toBe(' apple \n banana \n orange ');
|
||||
});
|
||||
|
||||
test('should handle regex split', () => {
|
||||
const input = 'apple banana orange';
|
||||
const result = TopItemsList('regex', '\\s+', '\n', input, false, false, false, false);
|
||||
expect(result).toBe('apple\nbanana\norange');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user