Skip to content

Commit 27417b5

Browse files
committed
html2NodeArr test
1 parent b68e560 commit 27417b5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/CssChain-helpers.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,33 @@ describe( 'CssChain internal helpers', () =>
179179
expect( arr[1].outerHTML).to.eq('<i>World</i>');
180180
expect( arr[2].outerHTML).to.eq('<b>!</b>');
181181
});
182+
it( 'html2NodeArr(node) ', async ()=>
183+
{
184+
const d = document.createElement('div');
185+
d.innerHTML = `<a>A</a>B<i>C</i>`
186+
const arr = html2NodeArr(d)
187+
expect( arr.length).to.eq(1);
188+
expect( arr[0].textContent).to.eq('ABC');
189+
});
190+
it( 'html2NodeArr(node) ', async ()=>
191+
{
192+
const d = document.createElement('div');
193+
d.innerHTML = `<a>A</a>B<i>C</i>`
194+
const arr = html2NodeArr(d.childNodes)
195+
expect( arr.length).to.eq(3);
196+
expect( arr[0].outerHTML).to.eq('<a>A</a>');
197+
expect( arr[1].textContent).to.eq('B');
198+
expect( arr[2].outerHTML).to.eq('<i>C</i>');
199+
});
200+
it( 'html2NodeArr(A) ', async ()=>
201+
{
202+
const d = document.createElement('div');
203+
d.innerHTML = '<a slot="link-url" href="../doc.png"></a>';
204+
const arr = html2NodeArr(d.childNodes[0])
205+
expect( arr.length).to.eq(1);
206+
expect( arr[0].tagName).to.eq('A');
207+
expect( arr[0].textContent).to.eq('');
208+
expect( arr[0].getAttribute('slot')).to.eq('link-url');
209+
});
182210

183211
} );

0 commit comments

Comments
 (0)