|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import StringUtils from '../../lib/stringUtils.js'; |
| 3 | + |
| 4 | +describe('StringUtils', () => { |
| 5 | + describe('toKebabCase', () => { |
| 6 | + it('should convert a string to kebab case', () => { |
| 7 | + expect(StringUtils.toKebabCase('Hello World')).toBe('hello-world'); |
| 8 | + }); |
| 9 | + }); |
| 10 | + |
| 11 | + describe('convertToSeoSlug', () => { |
| 12 | + it('should convert a string to a SEO slug', () => { |
| 13 | + expect(StringUtils.convertToSeoSlug('Hello World')).toBe('/hello-world'); |
| 14 | + }); |
| 15 | + }); |
| 16 | + |
| 17 | + describe('stripHtmlParagraphsAndLinks', () => { |
| 18 | + it('should strip HTML paragraphs and links', () => { |
| 19 | + expect( |
| 20 | + StringUtils.stripHtmlParagraphsAndLinks( |
| 21 | + '<p><a href="http://example.com">Hello</a></p>' |
| 22 | + ) |
| 23 | + ).toBe('Hello'); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + describe('stripHtml', () => { |
| 28 | + it('should strip HTML', () => { |
| 29 | + expect(StringUtils.stripHtml('<p>Hello & hi!</p>')).toBe( |
| 30 | + 'Hello & hi!' |
| 31 | + ); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + describe('normalizedTokens', () => { |
| 36 | + it('should normalize tokens', () => { |
| 37 | + expect(StringUtils.normalizedTokens('Hello a World!')).toEqual([ |
| 38 | + 'hello', |
| 39 | + 'world', |
| 40 | + ]); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('escapeHtml', () => { |
| 45 | + it('should escape HTML', () => { |
| 46 | + expect(StringUtils.escapeHtml('Hello & "world"')).toBe( |
| 47 | + 'Hello & "world"' |
| 48 | + ); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + describe('formatTag', () => { |
| 53 | + it('should format a tag', () => { |
| 54 | + expect(StringUtils.formatTag('hello')).toBe('Hello'); |
| 55 | + }); |
| 56 | + }); |
| 57 | +}); |
0 commit comments