|
|
@ -4,3 +4,26 @@ import createNode from '../dist/create-node'; |
|
|
|
test('createNode should be a function', t => { |
|
|
|
t.is(typeof createNode, 'function'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('createNode(markup) should create an HTMLElement DOM node', t => { |
|
|
|
const domNode = createNode('<div></div>'); |
|
|
|
t.true(domNode instanceof window.HTMLElement); |
|
|
|
}); |
|
|
|
|
|
|
|
test('DOM node should match markup', t => { |
|
|
|
const markup = ` |
|
|
|
<div> |
|
|
|
<span>hello</span> |
|
|
|
<span>world</span> |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
const expectedText = ['hello', 'world']; |
|
|
|
const domNode = createNode(markup); |
|
|
|
|
|
|
|
t.true(domNode instanceof window.HTMLDivElement); |
|
|
|
t.is(domNode.children.length, 2); |
|
|
|
Array.from(domNode.children).forEach((childNode, i) => { |
|
|
|
t.true(childNode instanceof window.HTMLSpanElement); |
|
|
|
t.is(childNode.textContent, expectedText[i]); |
|
|
|
}); |
|
|
|
}); |
|
|
|