mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-06 06:17:11 -04:00
feat(new tool): string obfuscator (#575)
This commit is contained in:
parent
f235dcd6c1
commit
c58d6e3423
6 changed files with 119 additions and 1 deletions
20
src/tools/string-obfuscator/string-obfuscator.model.test.ts
Normal file
20
src/tools/string-obfuscator/string-obfuscator.model.test.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { obfuscateString } from './string-obfuscator.model';
|
||||
|
||||
describe('string-obfuscator model', () => {
|
||||
describe('obfuscateString', () => {
|
||||
it('the characters in the middle of the string are replaced by the replacement character', () => {
|
||||
expect(obfuscateString('1234567890')).toBe('1234******');
|
||||
expect(obfuscateString('1234567890', { replacementChar: 'x' })).toBe('1234xxxxxx');
|
||||
expect(obfuscateString('1234567890', { keepFirst: 5 })).toBe('12345*****');
|
||||
expect(obfuscateString('1234567890', { keepFirst: 0, keepLast: 5 })).toBe('*****67890');
|
||||
expect(obfuscateString('1234567890', { keepFirst: 5, keepLast: 5 })).toBe('1234567890');
|
||||
expect(obfuscateString('1234567890', { keepFirst: 2, keepLast: 2, replacementChar: 'x' })).toBe('12xxxxxx90');
|
||||
});
|
||||
|
||||
it('by default, the spaces are kept, they can be removed with the keepSpace option', () => {
|
||||
expect(obfuscateString('12345 67890')).toBe('1234* *****');
|
||||
expect(obfuscateString('12345 67890', { keepSpace: false })).toBe('1234*******');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue