Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

text.test.ts 731 B

You have to be logged in to leave a comment. Sign In
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
  1. import { ellipsize } from '../../src/util/text';
  2. describe('ellipsize', () => {
  3. it('should not modify string shorter than maxLen', () => {
  4. const str = 'hello';
  5. expect(ellipsize(str, 10)).toBe('hello');
  6. });
  7. it('should truncate string and add ellipsis when longer than maxLen', () => {
  8. const str = 'hello world';
  9. expect(ellipsize(str, 8)).toBe('hello...');
  10. });
  11. it('should handle string equal to maxLen', () => {
  12. const str = 'hello';
  13. expect(ellipsize(str, 5)).toBe('hello');
  14. });
  15. it('should handle very short maxLen', () => {
  16. const str = 'hello';
  17. expect(ellipsize(str, 4)).toBe('h...');
  18. });
  19. it('should handle empty string', () => {
  20. expect(ellipsize('', 5)).toBe('');
  21. });
  22. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...