Skip to content

Commit

Permalink
Refactor to use node:test
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 23, 2023
1 parent 1946cf3 commit 07cd479
Show file tree
Hide file tree
Showing 16 changed files with 606 additions and 305 deletions.
12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,25 @@
"dependencies": {
"@types/mdast": "^4.0.0",
"hast-util-sanitize": "^5.0.0",
"hast-util-to-html": "^9.0.0",
"mdast-util-to-hast": "^13.0.0",
"unified": "^11.0.0"
},
"devDependencies": {
"@types/hast": "^3.0.0",
"@types/tape": "^5.0.0",
"@types/node": "^20.0.0",
"c8": "^8.0.0",
"commonmark.json": "^0.30.0",
"is-hidden": "^2.0.0",
"hast-util-from-html": "^2.0.0",
"hast-util-to-html": "^9.0.0",
"prettier": "^3.0.0",
"rehype-parse": "^9.0.0",
"rehype-stringify": "^10.0.0",
"remark": "^15.0.0",
"remark-cli": "^11.0.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.0",
"remark-github": "^12.0.0",
"remark-parse": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"remark-slug": "^7.0.0",
"remark-toc": "^9.0.0",
"tape": "^5.0.0",
"to-vfile": "^8.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"vfile": "^6.0.0",
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/blockquote/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>Block Quote</h1>
<blockquote>
<ul>
<li>
<pre><code>code.in.a.list();
</code></pre>
</li>
<li>
<p>Paragraph.</p>
</li>
<li>
<p>Normal list</p>
</li>
</ul>
<p>Paragraph.</p>
</blockquote>
14 changes: 14 additions & 0 deletions test/fixtures/code/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h1>Code</h1>
<pre><code class="language-js">alert('some JavaScript code.');
</code></pre>
<pre><code>foo bar baz
</code></pre>
<pre><code>alpha bravo charlie
</code></pre>
<pre><code class="language-empty"></code></pre>
<pre><code class="language-tabs"> two spaces
one
two
one
mixed.
</code></pre>
31 changes: 31 additions & 0 deletions test/fixtures/entities-named/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h1>Entities</h1>
<p>Plain text:</p>
<p>AT&amp;T with entity, AT&amp;T with numeric entity, AT&amp;T without entity.</p>
<p>Fenced code language flags:</p>
<pre><code class="language-AT&amp;T">Something in the AT&amp;amp;T language
</code></pre>
<pre><code class="language-AT&amp;T">Something in the AT&amp;#x26;T language
</code></pre>
<pre><code class="language-AT&amp;T">Something in the AT&amp;T language
</code></pre>
<p>Automatic links:</p>
<p><a href="http://at&amp;amp;t.com">http://at&amp;amp;t.com</a>, <a href="http://at&amp;#x26;t.com">http://at&amp;#x26;t.com</a>, and <a href="http://at&amp;t.com">http://at&amp;t.com</a>.</p>
<p>Link <code>href</code>:</p>
<p><a href="http://at&amp;t.com">With entity</a>, <a href="http://at&amp;t.com">numeric entity</a>, <a href="http://at&amp;t.com">without entity</a>.</p>
<p>Link <code>title</code>:</p>
<p><a href="http://att.com" title="AT&amp;T">With entity</a>, <a href="http://att.com" title="AT&amp;T">numeric entity</a>, <a href="http://example.com" title="AT&amp;T">without entity</a>.</p>
<p>Image <code>src</code>:</p>
<p><img src="http://at&amp;t.com/fav.ico" alt="With entity">, <img src="http://at&amp;t.com/fav.ico" alt="numeric entity">, <img src="http://at&amp;t.com/fav.ico" alt="without entity">.</p>
<p>Image <code>alt</code>:</p>
<p><img src="http://att.com/fav.ico" alt="AT&amp;T with entity">, <img src="http://att.com/fav.ico" alt="AT&amp;T with numeric entity">, <img src="http://att.com/fav.ico" alt="AT&amp;T without entity">.</p>
<p>Image <code>title</code>:</p>
<p><img src="http://att.com/fav.ico" alt="With entity" title="AT&amp;T">, <img src="http://att.com/fav.ico" alt="numeric entity" title="AT&amp;T">, <img src="http://att.com/fav.ico" alt="without entity" title="AT&amp;T">.</p>
<p>Reference <code>link</code>:</p>
<p><a href="http://at&amp;t.com/fav.ico" title="ATT favicon">Entity</a>, <a href="http://at&amp;t.com/fav.ico" title="ATT favicon">Numeric entity</a>, <a href="http://at&amp;t.com/fav.ico" title="ATT favicon">Literal</a>.</p>
<p><img src="http://at&amp;t.com/fav.ico" alt="Entity" title="ATT favicon">, <img src="http://at&amp;t.com/fav.ico" alt="Numeric entity" title="ATT favicon">, <img src="http://at&amp;t.com/fav.ico" alt="Literal" title="ATT favicon">.</p>
<p>Reference <code>title</code>:</p>
<p><a href="http://at&amp;t.com/fav.ico" title="AT&amp;T favicon">Entity</a>, <a href="http://at&amp;t.com/fav.ico" title="AT&amp;T favicon">Numeric entity</a>, <a href="http://at&amp;t.com/fav.ico" title="AT&amp;T favicon">Literal</a>.</p>
<p><img src="http://at&amp;t.com/fav.ico" alt="Entity" title="AT&amp;T favicon">, <img src="http://at&amp;t.com/fav.ico" alt="Numeric entity" title="AT&amp;T favicon">, <img src="http://at&amp;t.com/fav.ico" alt="Literal" title="AT&amp;T favicon">.</p>
<p>Image Reference <code>alt</code>:</p>
<p><img src="http://at&amp;t.com/fav.ico" alt="AT&amp;T with entity" title="AT&amp;T favicon">, <img src="http://at&amp;t.com/fav.ico" alt="AT&amp;T with numeric entity" title="AT&amp;T favicon">, <img src="http://at&amp;t.com/fav.ico" alt="AT&amp;T without entity" title="AT&amp;T favicon">.</p>
<p>Definitions:</p>
31 changes: 31 additions & 0 deletions test/fixtures/entities-numerical/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<h1>Entities</h1>
<p>Plain text:</p>
<p>AT&#x26;T with entity, AT&#x26;T with numeric entity, AT&#x26;T without entity.</p>
<p>Fenced code language flags:</p>
<pre><code class="language-AT&#x26;T">Something in the AT&#x26;amp;T language
</code></pre>
<pre><code class="language-AT&#x26;T">Something in the AT&#x26;#x26;T language
</code></pre>
<pre><code class="language-AT&#x26;T">Something in the AT&#x26;T language
</code></pre>
<p>Automatic links:</p>
<p><a href="http://at&#x26;amp;t.com">http://at&#x26;amp;t.com</a>, <a href="http://at&#x26;#x26;t.com">http://at&#x26;#x26;t.com</a>, and <a href="http://at&#x26;t.com">http://at&#x26;t.com</a>.</p>
<p>Link <code>href</code>:</p>
<p><a href="http://at&#x26;t.com">With entity</a>, <a href="http://at&#x26;t.com">numeric entity</a>, <a href="http://at&#x26;t.com">without entity</a>.</p>
<p>Link <code>title</code>:</p>
<p><a href="http://att.com" title="AT&#x26;T">With entity</a>, <a href="http://att.com" title="AT&#x26;T">numeric entity</a>, <a href="http://example.com" title="AT&#x26;T">without entity</a>.</p>
<p>Image <code>src</code>:</p>
<p><img src="http://at&#x26;t.com/fav.ico" alt="With entity">, <img src="http://at&#x26;t.com/fav.ico" alt="numeric entity">, <img src="http://at&#x26;t.com/fav.ico" alt="without entity">.</p>
<p>Image <code>alt</code>:</p>
<p><img src="http://att.com/fav.ico" alt="AT&#x26;T with entity">, <img src="http://att.com/fav.ico" alt="AT&#x26;T with numeric entity">, <img src="http://att.com/fav.ico" alt="AT&#x26;T without entity">.</p>
<p>Image <code>title</code>:</p>
<p><img src="http://att.com/fav.ico" alt="With entity" title="AT&#x26;T">, <img src="http://att.com/fav.ico" alt="numeric entity" title="AT&#x26;T">, <img src="http://att.com/fav.ico" alt="without entity" title="AT&#x26;T">.</p>
<p>Reference <code>link</code>:</p>
<p><a href="http://at&#x26;t.com/fav.ico" title="ATT favicon">Entity</a>, <a href="http://at&#x26;t.com/fav.ico" title="ATT favicon">Numeric entity</a>, <a href="http://at&#x26;t.com/fav.ico" title="ATT favicon">Literal</a>.</p>
<p><img src="http://at&#x26;t.com/fav.ico" alt="Entity" title="ATT favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="Numeric entity" title="ATT favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="Literal" title="ATT favicon">.</p>
<p>Reference <code>title</code>:</p>
<p><a href="http://at&#x26;t.com/fav.ico" title="AT&#x26;T favicon">Entity</a>, <a href="http://at&#x26;t.com/fav.ico" title="AT&#x26;T favicon">Numeric entity</a>, <a href="http://at&#x26;t.com/fav.ico" title="AT&#x26;T favicon">Literal</a>.</p>
<p><img src="http://at&#x26;t.com/fav.ico" alt="Entity" title="AT&#x26;T favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="Numeric entity" title="AT&#x26;T favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="Literal" title="AT&#x26;T favicon">.</p>
<p>Image Reference <code>alt</code>:</p>
<p><img src="http://at&#x26;t.com/fav.ico" alt="AT&#x26;T with entity" title="AT&#x26;T favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="AT&#x26;T with numeric entity" title="AT&#x26;T favicon">, <img src="http://at&#x26;t.com/fav.ico" alt="AT&#x26;T without entity" title="AT&#x26;T favicon">.</p>
<p>Definitions:</p>
39 changes: 39 additions & 0 deletions test/fixtures/escape-commonmark/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<p>These should all get escaped:</p>
<p>Backslash: \</p>
<p>Backtick: `</p>
<p>Asterisk: *</p>
<p>Underscore: _</p>
<p>Left brace: {</p>
<p>Right brace: }</p>
<p>Left bracket: [</p>
<p>Right bracket: ]</p>
<p>Left paren: (</p>
<p>Right paren: )</p>
<p>Greater-than: ></p>
<p>Hash: #</p>
<p>Period: .</p>
<p>Bang: !</p>
<p>Plus: +</p>
<p>Minus: -</p>
<p><strong>GFM:</strong></p>
<p>Pipe: |</p>
<p>Tilde: ~</p>
<p><strong>Commonmark:</strong></p>
<p>Quote: "</p>
<p>Dollar: $</p>
<p>Percentage: %</p>
<p>Ampersand: &#x26;</p>
<p>Single quote: '</p>
<p>Comma: ,</p>
<p>Forward slash: /</p>
<p>Colon: :</p>
<p>Semicolon: ;</p>
<p>Less-than: &#x3C;</p>
<p>Equals: =</p>
<p>Question mark: ?</p>
<p>At-sign: @</p>
<p>Caret: ^</p>
<p>New line: <br>
only works in paragraphs.</p>
<p>Two spaces:<br>
only works in paragraphs.</p>
39 changes: 39 additions & 0 deletions test/fixtures/escape/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<p>These should all get escaped:</p>
<p>Backslash: \</p>
<p>Backtick: `</p>
<p>Asterisk: *</p>
<p>Underscore: _</p>
<p>Left brace: {</p>
<p>Right brace: }</p>
<p>Left bracket: [</p>
<p>Right bracket: ]</p>
<p>Left paren: (</p>
<p>Right paren: )</p>
<p>Greater-than: ></p>
<p>Hash: #</p>
<p>Period: .</p>
<p>Bang: !</p>
<p>Plus: +</p>
<p>Minus: -</p>
<p><strong>GFM:</strong></p>
<p>Pipe: |</p>
<p>Tilde: ~</p>
<p><strong>Commonmark:</strong></p>
<p>Quote: "</p>
<p>Dollar: $</p>
<p>Percentage: %</p>
<p>Ampersand: &#x26;</p>
<p>Single quote: '</p>
<p>Comma: ,</p>
<p>Forward slash: /</p>
<p>Colon: :</p>
<p>Semicolon: ;</p>
<p>Less-than: &#x3C;</p>
<p>Equals: =</p>
<p>Question mark: ?</p>
<p>At-sign: @</p>
<p>Caret: ^</p>
<p>New line: <br>
only works in paragraphs.</p>
<p>Two spaces:<br>
only works in paragraphs.</p>
3 changes: 3 additions & 0 deletions test/fixtures/html-sanitize/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>Foo bar baz qux.</p>
<h1>heading</h1>
<p>Alpha <a>bravo</a> charlie.</p>
2 changes: 2 additions & 0 deletions test/fixtures/html/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Alpha</h1>
<p><strong>Foo</strong> <em>bar</em> <sup>baz</sup> <sub>qux</sub>.</p>
6 changes: 6 additions & 0 deletions test/fixtures/images/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p><img src="http://example.com/favicon.ico" alt="Example" title="Example Image"></p>
<p><img src="http://example.com/favicon.ico" alt="Example"></p>
<p><img src="http://example.com/favicon.ico" alt=""></p>
<p><img src="" alt="" title="Example Image"></p>
<p><img src="" alt=""></p>
<p><img src="" alt=""></p>
6 changes: 6 additions & 0 deletions test/fixtures/links/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p><a href="http://example.com" title="Example Link">Example</a></p>
<p><a href="http://example.com">Example</a></p>
<p><a href="http://example.com"></a></p>
<p><a href="" title="Example Link"></a></p>
<p><a href=""></a></p>
<p><a href=""></a></p>
36 changes: 36 additions & 0 deletions test/fixtures/list/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<h1>List</h1>
<ul>
<li><strong>One</strong>;</li>
<li><em>Two</em>;</li>
<li>~~Three~~.</li>
</ul>
<ol>
<li>One;</li>
<li>Two;</li>
</ol>
<!-- -->
<ol start="4">
<li>Four.</li>
<li>Five.</li>
</ol>
<ul>
<li>
<p>Loose:</p>
<ul>
<li>Alpha;</li>
<li>Bravo;</li>
<li>Charlie.</li>
</ul>
</li>
<li>
<p>Loose 2:</p>
<ul>
<li>Delta;</li>
<li>Echo;</li>
<li>Foxtrot.</li>
</ul>
</li>
</ul>
<hr>
<pre><code>And a rule.
</code></pre>
6 changes: 6 additions & 0 deletions test/fixtures/references/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>References</h1>
<p>Entities contains some serious entity tests relating to titles and links
in definitions.</p>
<p>However, the [missing], [missing][], and [missing][missing] are omitted.</p>
<p>However, the ![missing], ![missing][], and ![missing][missing] are omitted.</p>
<p>Same goes for [][empty] and ![][empty].</p>
4 changes: 4 additions & 0 deletions test/fixtures/rule/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Horizontal Rules</h1>
<hr>
<hr>
<hr>
4 changes: 4 additions & 0 deletions test/fixtures/self-closing/output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>Hello<br />
world</p>
<hr />
<p><img src="http://exaple.com/fav.ico" alt="Favicon" title="Example Favicon" /></p>
Loading

0 comments on commit 07cd479

Please sign in to comment.