Skip to content

Commit 398d8d6

Browse files
authored
chore: #210 use self-closing tags in tests (#211)
1 parent e4916a4 commit 398d8d6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test/cases/html-web-components/expected.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<wcc-picture-frame title="Greenwood">
22
<div class="picture-frame">
3-
<img src="https://www.greenwoodjs.io/assets/greenwood-logo-og.png" alt="Greenwood logo">
4-
<br>
3+
<img src="https://www.greenwoodjs.io/assets/greenwood-logo-og.png" alt="Greenwood logo" />
4+
<br />
55
<span>Author: <span>WCC</span></span>
66
<wcc-caption>
77
<div class="caption">

test/cases/html-web-components/html-web-components.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import chai from 'chai';
1818
import { JSDOM } from 'jsdom';
1919
import fs from 'fs/promises';
2020
import { renderToString } from '../../../src/wcc.js';
21+
import { parseFragment, serialize } from 'parse5';
2122

2223
const expect = chai.expect;
2324

@@ -34,7 +35,10 @@ describe('Run WCC For ', function() {
3435
actualHtml = html;
3536
dom = new JSDOM(actualHtml);
3637
pictureFrame = dom.window.document.querySelectorAll('wcc-picture-frame');
37-
expectedHtml = await fs.readFile(new URL('./expected.html', import.meta.url), 'utf-8');
38+
39+
// We want to compare using canonical html (i.e. strip self-closing tags)
40+
const rawExpectedHtml = await fs.readFile(new URL('./expected.html', import.meta.url), 'utf-8');
41+
expectedHtml = serialize(parseFragment(rawExpectedHtml));
3842
});
3943

4044
describe(LABEL, function() {
@@ -79,7 +83,7 @@ describe('Run WCC For ', function() {
7983
});
8084

8185
it('should have the expected recursively generated HTML', () => {
82-
expect(expectedHtml.replace(/ /g, '').replace(/\n/g, '')).to.equal(actualHtml.replace(/ /g, '').replace(/\n/g, ''));
86+
expect(actualHtml.replace(/ /g, '').replace(/\n/g, '')).to.equal(expectedHtml.replace(/ /g, '').replace(/\n/g, ''));
8387
});
8488
});
8589
});

0 commit comments

Comments
 (0)