mdbadges-cli
Version:
An extensive CLI tool to find over 400+ Shields.io badges for your projects.
36 lines (32 loc) • 1.52 kB
JavaScript
import {
formatCategoryName,
searchCategory,
formatBadgeName,
escapeHtml,
} from '../src/utils';
describe('formatCategoryName', () => {
test('should format category names that have dashes between the spaces', () => {
const result = formatCategoryName('app-store');
expect(result).toBe('App Store');
});
});
describe('formatBadgeName', () => {
test('should format badge names that have dashes between the spaces', () => {
const result = formatBadgeName('discord');
expect(result).toBe('Discord');
});
});
describe('SearchCategory', () => {
test('should convert categories to lowercase by adding hyphens', () => {
const result = searchCategory('App Store');
expect(result).toBe('app-store');
});
});
describe('escapeHtml', () => {
test('should escape special characters in HTML string', () => {
const unsafeHtmlString = '<a href="https://discord.com">\n <img src="https://img.shields.io/badge/Discord-%235865F2.svg?&logo=discord&logoColor=white" alt="Discord">\n</a>';
const expectedHtmlString = '<a href="https://discord.com">\n <img src="https://img.shields.io/badge/Discord-%235865F2.svg?&logo=discord&logoColor=white" alt="Discord">\n</a>';
const result = escapeHtml(unsafeHtmlString);
expect(result).toBe(expectedHtmlString);
});
});