2024-07-07 09:32:30 -06:00
|
|
|
import {createElementFromAttrs, createElementFromHTML} from './dom.ts';
|
2024-06-07 07:42:31 -06:00
|
|
|
|
|
|
|
test('createElementFromHTML', () => {
|
|
|
|
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
|
|
|
});
|
2024-06-26 11:01:20 -06:00
|
|
|
|
|
|
|
test('createElementFromAttrs', () => {
|
|
|
|
const el = createElementFromAttrs('button', {
|
|
|
|
id: 'the-id',
|
|
|
|
class: 'cls-1 cls-2',
|
|
|
|
disabled: true,
|
2024-08-01 13:06:03 -06:00
|
|
|
checked: false,
|
2024-06-26 11:01:20 -06:00
|
|
|
required: null,
|
2024-08-01 13:06:03 -06:00
|
|
|
tabindex: 0,
|
2024-10-30 14:06:36 -06:00
|
|
|
'data-foo': 'the-data',
|
|
|
|
}, 'txt', createElementFromHTML('<span>inner</span>'));
|
|
|
|
expect(el.outerHTML).toEqual('<button id="the-id" class="cls-1 cls-2" disabled="" tabindex="0" data-foo="the-data">txt<span>inner</span></button>');
|
2024-06-26 11:01:20 -06:00
|
|
|
});
|