-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_clean_utils_test.ts
More file actions
38 lines (28 loc) · 1.54 KB
/
Copy pathstring_clean_utils_test.ts
File metadata and controls
38 lines (28 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { expect, test } from "bun:test";
import { StringCleanUtils } from "../";
test('Replaces diacritics & accents with original', () => {
const normalized = StringCleanUtils.normalize('𝒉𝒂𝒓𝒍𝒆𝒚𝒔 𝒊𝒏 𝒉𝒂𝒘𝒂𝒊𝒊 - 𝒌𝒂𝒕𝒚 𝒑𝒆𝒓𝒓𝒚');
const expected = 'harleys in hawaii - katy perry';
expect(normalized).toBe(expected);
});
test('Replaces diacritics & accents with original 2', () => {
const normalized = StringCleanUtils.normalize('𝑻𝒉𝒆 ℚ𝕦𝕚𝕔𝕜 Brown Fox 𝔍𝔲𝔪𝔭𝔢𝔡 ⓞⓥⓔⓡ ʇɥǝ 𝗟𝗮𝘇𝘆 𝙳𝚘𝚐');
const expected = 'The Quick Brown Fox Jumped over the Lazy Dog';
expect(normalized).toBe(expected);
});
test('Remove symbols from text', () => {
const normalized = StringCleanUtils.removeSymbols('The [Quick }Brown Fox %Jumped over ^the Lazy @Dog');
const expected = 'The Quick Brown Fox Jumped over the Lazy Dog';
expect(normalized).toBe(expected);
});
test('Remove symbols & whitespaces from text', () => {
const normalized = StringCleanUtils.removeSymbolsAndWhitespaces('The [Quick }Brown Fox %Jumped over ^the Lazy @Dog');
const expected = 'TheQuickBrownFoxJumpedovertheLazyDog';
expect(normalized).toBe(expected);
});
test('Ensure main letters are not changed', () => {
const lower = 'qwertyuiopasdfghjklzxcvbnm';
const upper = 'QWERTYUIOPASDFGHJKLZXCVBNM';
expect(StringCleanUtils.normalize(lower)).toBe(lower);
expect(StringCleanUtils.normalize(upper)).toBe(upper);
});