Skip to content

Commit cb4c4b0

Browse files
committed
Add tests for libs
1 parent a661812 commit cb4c4b0

2 files changed

Lines changed: 57 additions & 39 deletions

File tree

spec/lib/core_extensions/string_spec.rb

Lines changed: 0 additions & 39 deletions
This file was deleted.

spec/lib/stringUtils.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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&nbsp;&amp; 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 &amp; &quot;world&quot;'
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

Comments
 (0)