import {
clearCaches,
createAttributeTagFunctions,
createClassTagFunctions,
createElementTagFunctions,
tagFunctions,
wrapValues,
} from '../src/index';
beforeEach(() => {
clearCaches();
});
describe('createAttributeTagFunctions', () => {
test('simple', () => {
const fn = createAttributeTagFunctions([ 'a' ]).a;
const actual = fn([ '123' ]);
expect(actual).toBe(' a="123"');
});
});
describe('createClassTagFunctions', () => {
test('simple', () => {
const fn = createClassTagFunctions([ 'c' ]).c;
const actual = fn([ '123' ]);
expect(actual).toBe('123');
});
});
describe('createElementTagFunctions', () => {
test('simple', () => {
const fn = createElementTagFunctions([ 'e' ]).e;
const actual = fn([ '123' ]);
expect(actual).toBe('123');
});
test('with attributes', () => {
const fn = createElementTagFunctions([ 'e2' ]).e2;
const actual = fn([ ' a="123" bcd="456"789' ]);
expect(actual).toBe('789');
});
// test('with entities', () => {
// const fn = createElementTagFunctions([ 'e3' ]).e3;
// const actual = fn([ ' a="b&c"He said "hi".' ]);
// expect(actual).toBe('He said "hi".');
// });
});
describe('tagFunctions', () => {
test('li', () => {
const fn = tagFunctions.li;
const actual = fn([ 'content' ]);
expect(actual).toBe('
content');
});
test('link', () => {
const fn = tagFunctions.a;
const actual = fn([ 'content' ]);
expect(actual).toBe('content');
});
test('link with target', () => {
const fn = tagFunctions.a;
const actual = fn([ ' target="custom"content' ]);
expect(actual).toBe('content');
});
});
describe('wrapValues', () => {
test('simple', () => {
const values = {
value: 123
};
const wrapped = wrapValues(values);
expect(wrapped.value).toBe(123);
const fn = wrapped.li;
const taggedContent = fn([ 'content' ]);
expect(taggedContent).toBe('content');
});
});