Browse Source

Add tests for checking returned DOM node

pull/2/head
Luke Childs 9 years ago
parent
commit
83408a8819
  1. 23
      test/unit.js

23
test/unit.js

@ -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]);
});
});

Loading…
Cancel
Save