forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.string.test.js
More file actions
28 lines (23 loc) · 808 Bytes
/
Copy pathutils.string.test.js
File metadata and controls
28 lines (23 loc) · 808 Bytes
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
const { capitalize, toSnakeCase, truncate, slugify, mask } = require('../src/utils/string');
describe('string utils', () => {
it('capitalize', () => {
expect(capitalize('hello')).toBe('Hello');
expect(capitalize('')).toBe('');
});
it('toSnakeCase', () => {
expect(toSnakeCase('camelCase')).toBe('camel_case');
expect(toSnakeCase('myVarName')).toBe('my_var_name');
});
it('truncate', () => {
expect(truncate('hello', 10)).toBe('hello');
expect(truncate('hello world', 5)).toBe('hello...');
});
it('slugify', () => {
expect(slugify('Hello World!')).toBe('hello-world');
expect(slugify(' Nova Rewards ')).toBe('nova-rewards');
});
it('mask', () => {
expect(mask('1234567890', 4)).toBe('******7890');
expect(mask('abc', 4)).toBe('abc');
});
});