@technobuddha/library
Version:
A large library of useful functions
20 lines (15 loc) • 495 B
text/typescript
import { tag } from './tag.ts';
describe('tag', () => {
test('create a tag', () => {
expect(tag('text')).toBe('<span>text</span>');
});
test('should escape HTML', () => {
expect(tag('<tag>')).toBe('<span><tag></span>');
});
test('can specify tag name', () => {
expect(tag('text', 'div')).toBe('<div>text</div>');
});
test('can specify attributes', () => {
expect(tag('text', 'tag', { a: 'a', gt: '>' })).toBe('<tag a="a" gt=">">text</tag>');
});
});