Skip to content

Commit 19f5cb7

Browse files
committed
Add unit test
1 parent 4249e5d commit 19f5cb7

File tree

2 files changed

+147
-3
lines changed

2 files changed

+147
-3
lines changed

tsdoc/src/parser/__tests__/NodeParserHtml.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,14 @@ test('07 Closing tags, negative', () => {
107107
' */'
108108
].join('\n'));
109109
});
110+
111+
test('08 Unusual element names', () => {
112+
TestHelpers.parseAndMatchNodeParserSnapshot([
113+
'/**',
114+
' * <a1/>',
115+
' * <a-a>',
116+
' * <a--a>',
117+
' * <a.2>',
118+
' */'
119+
].join('\n'));
120+
});

tsdoc/src/parser/__tests__/__snapshots__/NodeParserHtml.test.ts.snap

Lines changed: 136 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ Object {
946946
"logMessages": Array [
947947
"(2,4): The HTML element has an invalid attribute: Expecting \\"=\\" after HTML attribute name",
948948
"(2,28): The \\">\\" character should be escaped using a backslash to avoid confusion with an HTML tag",
949-
"(3,4): The HTML element has an invalid attribute: An HTML name must be a sequence of letters separated by hyphens",
949+
"(3,4): The HTML element has an invalid attribute: Expecting \\"=\\" after HTML attribute name",
950950
"(3,28): The \\">\\" character should be escaped using a backslash to avoid confusion with an HTML tag",
951951
"(4,4): The HTML element has an invalid attribute: The HTML string is missing its closing quote",
952952
"(4,31): The \\">\\" character should be escaped using a backslash to avoid confusion with an HTML tag",
@@ -1011,9 +1011,9 @@ Object {
10111011
],
10121012
},
10131013
Object {
1014-
"errorLocation": "attr-",
1014+
"errorLocation": "two",
10151015
"errorLocationPrecedingToken": " ",
1016-
"errorMessage": "The HTML element has an invalid attribute: An HTML name must be a sequence of letters separated by hyphens",
1016+
"errorMessage": "The HTML element has an invalid attribute: Expecting [q]=[q] after HTML attribute name",
10171017
"kind": "ErrorText",
10181018
"nodes": Array [
10191019
Object {
@@ -1701,3 +1701,136 @@ Object {
17011701
},
17021702
}
17031703
`;
1704+
1705+
exports[`08 Unusual element names 1`] = `
1706+
Object {
1707+
"buffer": "/**[n] * [<]a1/[>][n] * [<]a-a[>][n] * [<]a--a[>][n] * [<]a.2[>][n] */",
1708+
"gaps": Array [],
1709+
"lines": Array [
1710+
"[<]a1/[>]",
1711+
"[<]a-a[>]",
1712+
"[<]a--a[>]",
1713+
"[<]a.2[>]",
1714+
],
1715+
"logMessages": Array [],
1716+
"nodes": Object {
1717+
"kind": "Comment",
1718+
"nodes": Array [
1719+
Object {
1720+
"kind": "Section",
1721+
"nodes": Array [
1722+
Object {
1723+
"kind": "Paragraph",
1724+
"nodes": Array [
1725+
Object {
1726+
"kind": "HtmlStartTag",
1727+
"nodes": Array [
1728+
Object {
1729+
"kind": "Excerpt: HtmlStartTag_OpeningDelimiter",
1730+
"nodeExcerpt": "[<]",
1731+
},
1732+
Object {
1733+
"kind": "Excerpt: HtmlStartTag_Name",
1734+
"nodeExcerpt": "a1",
1735+
},
1736+
Object {
1737+
"kind": "Excerpt: HtmlStartTag_ClosingDelimiter",
1738+
"nodeExcerpt": "/[>]",
1739+
},
1740+
],
1741+
},
1742+
Object {
1743+
"kind": "SoftBreak",
1744+
"nodes": Array [
1745+
Object {
1746+
"kind": "Excerpt: SoftBreak",
1747+
"nodeExcerpt": "[n]",
1748+
},
1749+
],
1750+
},
1751+
Object {
1752+
"kind": "HtmlStartTag",
1753+
"nodes": Array [
1754+
Object {
1755+
"kind": "Excerpt: HtmlStartTag_OpeningDelimiter",
1756+
"nodeExcerpt": "[<]",
1757+
},
1758+
Object {
1759+
"kind": "Excerpt: HtmlStartTag_Name",
1760+
"nodeExcerpt": "a-a",
1761+
},
1762+
Object {
1763+
"kind": "Excerpt: HtmlStartTag_ClosingDelimiter",
1764+
"nodeExcerpt": "[>]",
1765+
},
1766+
],
1767+
},
1768+
Object {
1769+
"kind": "SoftBreak",
1770+
"nodes": Array [
1771+
Object {
1772+
"kind": "Excerpt: SoftBreak",
1773+
"nodeExcerpt": "[n]",
1774+
},
1775+
],
1776+
},
1777+
Object {
1778+
"kind": "HtmlStartTag",
1779+
"nodes": Array [
1780+
Object {
1781+
"kind": "Excerpt: HtmlStartTag_OpeningDelimiter",
1782+
"nodeExcerpt": "[<]",
1783+
},
1784+
Object {
1785+
"kind": "Excerpt: HtmlStartTag_Name",
1786+
"nodeExcerpt": "a--a",
1787+
},
1788+
Object {
1789+
"kind": "Excerpt: HtmlStartTag_ClosingDelimiter",
1790+
"nodeExcerpt": "[>]",
1791+
},
1792+
],
1793+
},
1794+
Object {
1795+
"kind": "SoftBreak",
1796+
"nodes": Array [
1797+
Object {
1798+
"kind": "Excerpt: SoftBreak",
1799+
"nodeExcerpt": "[n]",
1800+
},
1801+
],
1802+
},
1803+
Object {
1804+
"kind": "HtmlStartTag",
1805+
"nodes": Array [
1806+
Object {
1807+
"kind": "Excerpt: HtmlStartTag_OpeningDelimiter",
1808+
"nodeExcerpt": "[<]",
1809+
},
1810+
Object {
1811+
"kind": "Excerpt: HtmlStartTag_Name",
1812+
"nodeExcerpt": "a.2",
1813+
},
1814+
Object {
1815+
"kind": "Excerpt: HtmlStartTag_ClosingDelimiter",
1816+
"nodeExcerpt": "[>]",
1817+
},
1818+
],
1819+
},
1820+
Object {
1821+
"kind": "SoftBreak",
1822+
"nodes": Array [
1823+
Object {
1824+
"kind": "Excerpt: SoftBreak",
1825+
"nodeExcerpt": "[n]",
1826+
},
1827+
],
1828+
},
1829+
],
1830+
},
1831+
],
1832+
},
1833+
],
1834+
},
1835+
}
1836+
`;

0 commit comments

Comments
 (0)