Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Added .html.test files for replace .js language tests #3148

Merged
merged 12 commits into from Oct 19, 2021
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -61,6 +61,7 @@
"mocha": "^6.2.0",
"node-fetch": "^2.6.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.4.1",
"pump": "^3.0.0",
"refa": "^0.9.1",
"regexp-ast-analysis": "^0.2.4",
Expand Down
19 changes: 13 additions & 6 deletions test-suite.html
Expand Up @@ -165,14 +165,21 @@ <h2 id="writing-tests-explaining-the-simplified-token-stream">Explaining the sim
<section id="writing-specific-tests">
<h1>Writing specific tests</h1>

<p>Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension <code>.js</code> instead of <code>.test</code>, you can make Prism highlight arbitrary pieces of code and check their HTML results.</p>
<p>Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension <code>.html.test</code> instead of <code>.test</code>, you can make Prism highlight arbitrary pieces of code and check their HTML results.</p>
<p>The language is determined by the folder containing the test file lies, as explained in the previous section.</p>
<p>The structure of your test file will look like this, for example:</p>
<pre><code>module.exports = {
'&amp;#x278a;': '&lt;span class="token entity" title="&amp;#x278a;">&amp;amp;#x278a;&lt;/span>',
'&amp;#182;': '&lt;span class="token entity" title="&amp;#182;">&amp;amp;#182;&lt;/span>',
};</code></pre>
<p>The keys are the codes which will be highlighted by Prism. The values are the expected results, as HTML.</p>
<pre><code class="language-html">&amp;amp;
&amp;#x41;

----------------------------------------------------

&lt;span class="token entity named-entity" title="&amp;amp;">&amp;amp;amp;&lt;/span>
&lt;span class="token entity" title="&amp;#x41;">&amp;amp;#x41;&lt;/span>

----------------------------------------------------

This is a comment explaining this test case.
</code></pre>
</section>

<section id="test-runner-tests">
Expand Down