Skip to content

Commit 0c77baa

Browse files
committed
Rudimentary tests for md2html.js
1 parent 4cbb078 commit 0c77baa

6 files changed

Lines changed: 256 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html text eol=lf
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><link rel="canonical" href="https://spec.openapis.org/oas/latest.html" /><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","editors":[],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script></head><body><style>#respec-ui { visibility: hidden; }#title { color: #578000; } #subtitle { color: #578000; }.dt-published { color: #578000; } .dt-published::before { content: "Published "; }h1,h2,h3,h4,h5,h6 { color: #578000; font-weight: normal; font-style: normal; }a[href] { color: #45512c; }body:not(.toc-inline) #toc h2 { color: #45512c; }table { display: block; width: 100%; overflow: auto; }table th { font-weight: 600; }table th, table td { padding: 6px 13px; border: 1px solid #dfe2e5; }table tr { background-color: #fff; border-top: 1px solid #c6cbd1; }table tr:nth-child(2n) { background-color: #f6f8fa; }pre { background-color: #f6f8fa !important; }code { color: #c83500 } th code { color: inherit }a.bibref { text-decoration: underline;}/**
2+
<ul>
3+
<li>GitHub Gist Theme</li>
4+
<li>Author : Louis Barranqueiro - <a href="https://github.com/LouisBarranqueiro">https://github.com/LouisBarranqueiro</a>
5+
*/</li>
6+
</ul>
7+
<p>.hljs {
8+
display: block;
9+
background: white;
10+
padding: 0.5em;
11+
color: #333333;
12+
overflow-x: auto;
13+
}</p>
14+
<p>.hljs-comment,
15+
.hljs-meta {
16+
color: #969896;
17+
}</p>
18+
<p>.hljs-string,
19+
.hljs-variable,
20+
.hljs-template-variable,
21+
.hljs-strong,
22+
.hljs-emphasis,
23+
.hljs-quote {
24+
color: #df5000;
25+
}</p>
26+
<p>.hljs-number {
27+
color: #008080;
28+
}</p>
29+
<p>.hljs-keyword,
30+
.hljs-selector-tag,
31+
.hljs-type {
32+
color: #a71d5d;
33+
}</p>
34+
<p>.hljs-literal,
35+
.hljs-symbol,
36+
.hljs-bullet,
37+
.hljs-attribute {
38+
color: #0086b3;
39+
}</p>
40+
<p>.hljs-section,
41+
.hljs-name {
42+
color: #63a35c;
43+
}</p>
44+
<p>.hljs-tag {
45+
color: #333333;
46+
}</p>
47+
<p>.hljs-title,
48+
.hljs-attr,
49+
.hljs-selector-id,
50+
.hljs-selector-class,
51+
.hljs-selector-attr,
52+
.hljs-selector-pseudo {
53+
color: #795da3;
54+
}</p>
55+
<p>.hljs-addition {
56+
color: #55a532;
57+
background-color: #eaffea;
58+
}</p>
59+
<p>.hljs-deletion {
60+
color: #bd2c00;
61+
background-color: #ffecec;
62+
}</p>
63+
<p>.hljs-link {
64+
text-decoration: underline;
65+
}
66+
</style><h1 id="title">OpenAPI Specification v30.0.1 </h1><p class="copyright">Copyright © 3001 the Linux Foundation</p><section class="notoc" id="abstract"><h2>What is the OpenAPI Specification?</h2>The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.</section><section class="override" id="sotd" data-max-toc="0"><h2>Status of This Document</h2>The source-of-truth for the specification is the GitHub markdown file referenced above.</section></p>
67+
<section><h1>Heading 1</h1>
68+
<p>Text for first chapter</p>
69+
<section class="override" id="conformance"><h2>Version 30.0.1</h2>
70+
<p>This is the conformance section</p>
71+
</section></section><section><h1>Heading 2</h1>
72+
<p>Text for first section</p>
73+
<section><h2>Heading 3</h2>
74+
<p>Text for first subsection</p>
75+
<table>
76+
<thead>
77+
<tr>
78+
<th>Version</th>
79+
<th>Date</th>
80+
</tr>
81+
</thead>
82+
<tbody>
83+
<tr>
84+
<td>30.0.1</td>
85+
<td>3001-04-01</td>
86+
</tr>
87+
</tbody>
88+
</table>
89+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Heading 1
2+
3+
Text for first chapter
4+
5+
## Version 30.0.1
6+
7+
This is the conformance section
8+
9+
## Heading 2
10+
11+
Text for first section
12+
13+
### Heading 3
14+
15+
Text for first subsection
16+
17+
18+
Version | Date
19+
--------|-----------
20+
30.0.1 | 3001-04-01
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><link rel="canonical" href="https://spec.openapis.org/oas/latest.html" /><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","editors":[],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script></head><body><style>#respec-ui { visibility: hidden; }#title { color: #578000; } #subtitle { color: #578000; }.dt-published { color: #578000; } .dt-published::before { content: "Published "; }h1,h2,h3,h4,h5,h6 { color: #578000; font-weight: normal; font-style: normal; }a[href] { color: #45512c; }body:not(.toc-inline) #toc h2 { color: #45512c; }table { display: block; width: 100%; overflow: auto; }table th { font-weight: 600; }table th, table td { padding: 6px 13px; border: 1px solid #dfe2e5; }table tr { background-color: #fff; border-top: 1px solid #c6cbd1; }table tr:nth-child(2n) { background-color: #f6f8fa; }pre { background-color: #f6f8fa !important; }code { color: #c83500 } th code { color: inherit }a.bibref { text-decoration: underline;}/**
2+
<ul>
3+
<li>GitHub Gist Theme</li>
4+
<li>Author : Louis Barranqueiro - <a href="https://github.com/LouisBarranqueiro">https://github.com/LouisBarranqueiro</a>
5+
*/</li>
6+
</ul>
7+
<p>.hljs {
8+
display: block;
9+
background: white;
10+
padding: 0.5em;
11+
color: #333333;
12+
overflow-x: auto;
13+
}</p>
14+
<p>.hljs-comment,
15+
.hljs-meta {
16+
color: #969896;
17+
}</p>
18+
<p>.hljs-string,
19+
.hljs-variable,
20+
.hljs-template-variable,
21+
.hljs-strong,
22+
.hljs-emphasis,
23+
.hljs-quote {
24+
color: #df5000;
25+
}</p>
26+
<p>.hljs-number {
27+
color: #008080;
28+
}</p>
29+
<p>.hljs-keyword,
30+
.hljs-selector-tag,
31+
.hljs-type {
32+
color: #a71d5d;
33+
}</p>
34+
<p>.hljs-literal,
35+
.hljs-symbol,
36+
.hljs-bullet,
37+
.hljs-attribute {
38+
color: #0086b3;
39+
}</p>
40+
<p>.hljs-section,
41+
.hljs-name {
42+
color: #63a35c;
43+
}</p>
44+
<p>.hljs-tag {
45+
color: #333333;
46+
}</p>
47+
<p>.hljs-title,
48+
.hljs-attr,
49+
.hljs-selector-id,
50+
.hljs-selector-class,
51+
.hljs-selector-attr,
52+
.hljs-selector-pseudo {
53+
color: #795da3;
54+
}</p>
55+
<p>.hljs-addition {
56+
color: #55a532;
57+
background-color: #eaffea;
58+
}</p>
59+
<p>.hljs-deletion {
60+
color: #bd2c00;
61+
background-color: #ffecec;
62+
}</p>
63+
<p>.hljs-link {
64+
text-decoration: underline;
65+
}
66+
</style><h1 id="title">OpenAPI Specification v30.0.1 </h1><p class="copyright">Copyright © 3001 the Linux Foundation</p><section class="notoc" id="abstract"><h2>What is the OpenAPI Specification?</h2>The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.</section><section class="override" id="sotd" data-max-toc="0"><h2>Status of This Document</h2>The source-of-truth for the specification is the GitHub markdown file referenced above.</section></p>
67+
<section><h1>Heading 1</h1>
68+
<p>Text for first chapter</p>
69+
<section class="override" id="conformance"><h2>Version 30.0.1</h2>
70+
<p>This is the conformance section</p>
71+
</section></section><section><h1>Heading 2</h1>
72+
<p>Text for first section</p>
73+
<section><h2>Heading 3</h2>
74+
<p>Text for first subsection</p>
75+
<table>
76+
<thead>
77+
<tr>
78+
<th>Version</th>
79+
<th>Date</th>
80+
</tr>
81+
</thead>
82+
<tbody>
83+
<tr>
84+
<td>30.0.1</td>
85+
<td>3001-04-01</td>
86+
</tr>
87+
</tbody>
88+
</table>
89+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Heading 1
2+
3+
Text for first chapter
4+
5+
### Version 30.0.1
6+
7+
This is the conformance section
8+
9+
## Heading 2
10+
11+
Text for first section
12+
13+
### Heading 3
14+
15+
Text for first subsection
16+
17+
18+
Version | Date
19+
--------|-----------
20+
30.0.1 | 3001-04-01

tests/md2html/md2html.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { readdirSync, readFileSync } from "node:fs";
2+
import { exec } from "node:child_process";
3+
import { resolve } from "node:path";
4+
import { describe, test, expect } from "vitest";
5+
6+
const folder = "./tests/md2html/fixtures/";
7+
describe("v3.0 - Validate examples", async () => {
8+
readdirSync(folder, { withFileTypes: true })
9+
.filter((entry) => entry.isFile() && /\.md$/.test(entry.name))
10+
.forEach((entry) => {
11+
test(entry.name, async () => {
12+
const expected = readFileSync(
13+
folder + entry.name.replace(".md", ".html"),
14+
"utf8",
15+
);
16+
const output = await md2html([entry.name], folder);
17+
expect(output.stdout).to.equal(expected);
18+
});
19+
});
20+
});
21+
22+
function md2html(args, cwd) {
23+
return new Promise((res) => {
24+
exec(
25+
`node ${resolve("./scripts/md2html/md2html.js")} ${args.join(" ")}`,
26+
{ cwd },
27+
(error, stdout, stderr) => {
28+
res({
29+
code: error?.code || 0,
30+
error,
31+
stdout,
32+
stderr,
33+
});
34+
},
35+
);
36+
});
37+
}

0 commit comments

Comments
 (0)