2024-06-26 17:01:20 +00:00
|
|
|
import {createElementFromAttrs, createElementFromHTML} from './dom.js';
|
2024-06-07 13:42:31 +00:00
|
|
|
|
|
|
|
test('createElementFromHTML', () => {
|
|
|
|
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
|
|
|
});
|
2024-06-26 17:01:20 +00:00
|
|
|
|
|
|
|
test('createElementFromAttrs', () => {
|
|
|
|
const el = createElementFromAttrs('button', {
|
|
|
|
id: 'the-id',
|
|
|
|
class: 'cls-1 cls-2',
|
|
|
|
'data-foo': 'the-data',
|
|
|
|
disabled: true,
|
|
|
|
required: null,
|
|
|
|
});
|
|
|
|
expect(el.outerHTML).toEqual('<button id="the-id" class="cls-1 cls-2" data-foo="the-data" disabled=""></button>');
|
|
|
|
});
|