2024-07-07 11:32:30 -04:00
|
|
|
import {createElementFromAttrs, createElementFromHTML} from './dom.ts';
|
2024-06-07 09:42:31 -04:00
|
|
|
|
|
|
|
test('createElementFromHTML', () => {
|
|
|
|
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
|
|
|
});
|
2024-06-26 13:01:20 -04: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>');
|
|
|
|
});
|