Skip to content

Commit 179be2e

Browse files
committed
test(string): hideString添加replacementLen选项,支持替换字符不等于实际字符数量
1 parent f4ab9ab commit 179be2e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

__tests__/string.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ describe('string', function () {
197197
expect(hideString('👨‍👨‍👧‍👦helloworld👨‍👨‍👧‍👦', { start: 1, end: -1 })).toBe('👨‍👨‍👧‍👦**********👨‍👨‍👧‍👦');
198198
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { start: 1, end: -1 })).toBe('👨‍👨‍👧‍👦***********👨‍👨‍👧‍👦');
199199
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { start: -12, end: -1 })).toBe('👨‍👨‍👧‍👦***********👨‍👨‍👧‍👦');
200+
201+
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { start: -12, end: -1, replacementLen: 1 })).toBe(
202+
'👨‍👨‍👧‍👦*👨‍👨‍👧‍👦',
203+
);
200204
});
201205

202206
it('start,len', () => {
@@ -213,6 +217,10 @@ describe('string', function () {
213217

214218
expect(hideString('👨‍👨‍👧‍👦helloworld👨‍👨‍👧‍👦', { start: 1, len: 10 })).toBe('👨‍👨‍👧‍👦**********👨‍👨‍👧‍👦');
215219
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { start: 1, len: 11 })).toBe('👨‍👨‍👧‍👦***********👨‍👨‍👧‍👦');
220+
221+
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { start: 1, len: 11, replacementLen: 1 })).toBe(
222+
'👨‍👨‍👧‍👦*👨‍👨‍👧‍👦',
223+
);
216224
});
217225
it('len,end', () => {
218226
expect(hideString('helloworld')).toBe('**********');
@@ -225,6 +233,8 @@ describe('string', function () {
225233

226234
expect(hideString('👨‍👨‍👧‍👦helloworld👨‍👨‍👧‍👦', { len: 10, end: -1 })).toBe('👨‍👨‍👧‍👦**********👨‍👨‍👧‍👦');
227235
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { len: 11, end: -1 })).toBe('👨‍👨‍👧‍👦***********👨‍👨‍👧‍👦');
236+
237+
expect(hideString('👨‍👨‍👧‍👦hello👨‍👨‍👧world👨‍👨‍👧‍👦', { len: 11, end: -1, replacementLen: 1 })).toBe('👨‍👨‍👧‍👦*👨‍👨‍👧‍👦');
228238
});
229239
});
230240
test('getClassNames', () => {

0 commit comments

Comments
 (0)