-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtextUtils.test.js
More file actions
32 lines (26 loc) · 1.16 KB
/
Copy pathtextUtils.test.js
File metadata and controls
32 lines (26 loc) · 1.16 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
import { describe, expect, test } from 'vitest';
import { truncateText, truncateTextEnd } from '@/core/utils/textUtils.js';
describe('truncateText', () => {
test('should return the original text if it is shorter than maxLength', () => {
expect(truncateText('Hello', 10)).toBe('Hello');
});
test('should truncate text with dots in the middle if it is longer than maxLength', () => {
expect(truncateText('Hello World', 7)).toBe('He ..... ld');
});
test('should use default maxLength if not provided', () => {
const longText = 'This is a very long text that should be truncated';
expect(truncateText(longText)).not.toBe(longText);
});
});
describe('truncateTextEnd', () => {
test('should return the original text if it is shorter than maxLength', () => {
expect(truncateTextEnd('Hello', 10)).toBe('Hello');
});
test('should truncate text with dots at the end if it is longer than maxLength', () => {
expect(truncateTextEnd('Hello World', 8)).toBe('Hello...');
});
test('should use default maxLength if not provided', () => {
const longText = 'This is a very long text that should be truncated';
expect(truncateTextEnd(longText)).not.toBe(longText);
});
});