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,
|
2024-08-01 15:06:03 -04:00
|
|
|
checked: false,
|
2024-06-26 13:01:20 -04:00
|
|
|
required: null,
|
2024-08-01 15:06:03 -04:00
|
|
|
tabindex: 0,
|
2024-06-26 13:01:20 -04:00
|
|
|
});
|
2024-08-01 15:06:03 -04:00
|
|
|
expect(el.outerHTML).toEqual('<button id="the-id" class="cls-1 cls-2" data-foo="the-data" disabled="" tabindex="0"></button>');
|
2024-06-26 13:01:20 -04:00
|
|
|
});
|