Skip to content

Commit 943e2d3

Browse files
test: add snapshot to verify tags inside of <title> are escaped
1 parent 07e1055 commit 943e2d3

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

test/__snapshots__/index.test.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`HTMLReactParser escapes tags inside of <title> 1`] = `
4+
<title>
5+
&lt;em&gt;text&lt;/em&gt;
6+
</title>
7+
`;
8+
39
exports[`HTMLReactParser parses SVG 1`] = `
410
<svg
511
height="400"

test/data/html.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
void: '<link/><meta/><img/><br/><hr/><input/>',
1414
comment: '<!-- comment -->',
1515
doctype: '<!DOCTYPE html>',
16+
title: '<title><em>text</em></title>',
1617
customElement:
1718
'<custom-element class="myClass" custom-attribute="value" style="-o-transition: all .5s; line-height: 1;"></custom-element>'
1819
};

test/index.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ describe('HTMLReactParser', () => {
7575
const reactElement = parse('<i>' + encodedEntities + '</i>');
7676
expect(reactElement.props.children).toBe(decodedEntities);
7777
});
78+
79+
it('escapes tags inside of <title>', () => {
80+
expect(parse(html.title)).toMatchSnapshot();
81+
});
7882
});
7983

8084
describe('replace option', () => {

0 commit comments

Comments
 (0)