Skip to content

Commit

Permalink
Merge 1c32fbe into 7bc7c8a
Browse files Browse the repository at this point in the history
  • Loading branch information
sunesimonsen committed Nov 25, 2019
2 parents 7bc7c8a + 1c32fbe commit 519afab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -286,8 +286,9 @@ module.exports = {
);
},
equal(a, b) {
return a.nodeValue === b.nodeValue;
return a.nodeType === b.nodeType && a.nodeValue === b.nodeValue;
},
diff: () => {},
inspect(element, depth, output) {
return output.code(
`${element.nodeName} "${element.nodeValue}"`,
Expand Down
25 changes: 25 additions & 0 deletions test/index.spec.js
Expand Up @@ -1678,6 +1678,31 @@ describe('unexpected-dom', () => {
`
);
});

describe('on nodes of different types', () => {
it('should fail', () => {
expect(
() => {
expect(
parseHtmlNode(
'<ul><li>John</li><li class="winner">Jane</li><li>Annie</li></ul>'
),
'to equal',
parseHtmlDocument(
'<!DOCTYPE html><html><body><h1>Tournament</h1><ul><li>John</li><li>Jane</li><li class="winner">Annie</li></ul></body></html>'
)
);
},
'to throw an error satisfying to equal snapshot',
expect.unindent`
expected <ul><li>John</li><li class="winner">Jane</li><li>Annie</li></ul>
to equal <!DOCTYPE html><html><head></head><body>...</body></html>
`
);
});
});
});

describe('on text nodes', () => {
Expand Down

0 comments on commit 519afab

Please sign in to comment.