Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Before creating a pull request or marking a draft pull request as ready for revi
| `yarn validate-markdown` | markdownlint + link check only — fast loop while editing |
| `yarn format-markdown` | auto-fix markdownlint violations |
| `yarn build-src` | full check: validation, HTML build, schema publish |
| `yarn test` | runs the JSON Schema and build tooling test suites |
| `yarn test` | runs the repository's JSON Schema and Markdown rendering fixture tests |

5. After `yarn build-src`, open output file `deploy-preview/oas.html` with a browser and check your changes

Expand Down
11 changes: 11 additions & 0 deletions spec.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
"schema.yaml",
"schema-base.yaml"
],
"tests": {
"md2html": {
"fixtures": "tests/md2html/fixtures",
"config": "spec.config.json",
"otherVersions": [
"path/31.0.0.md",
"path/30.0.1.md",
"path/30.0.0.md"
]
}
},
"release": {
"sourcePath": "src/oas.md",
"releaseHistoryNote": "$releaseType of the OpenAPI Specification $version",
Expand Down
35 changes: 0 additions & 35 deletions tests/md2html/fixtures/spec.config.json

This file was deleted.

50 changes: 2 additions & 48 deletions tests/md2html/md2html.test.mjs
Original file line number Diff line number Diff line change
@@ -1,49 +1,3 @@
import { readdirSync, readFileSync } from "node:fs";
import { execFile } from "node:child_process";
import { resolve } from "node:path";
import { describe, test, expect } from "@oai/build-infra/test";
import assert from "node:assert";
import { registerMd2htmlFixtureTests } from "@oai/build-infra/test/md2html";

const folder = "./tests/md2html/fixtures/";
describe("md2html", async () => {
readdirSync(folder, { withFileTypes: true })
.filter((entry) => entry.isFile() && /\.md$/.test(entry.name))
.forEach((entry) => {
test(entry.name, async () => {
const expected = readFileSync(
folder + entry.name.replace(".md", ".html"),
"utf8",
);
const output = await md2html(
[
"--spec-config",
"spec.config.json",
"--maintainers",
entry.name.replace(".md", ".maintainers"),
entry.name,
"path/31.0.0.md\npath/30.0.1.md\npath/30.0.0.md",
],
folder,
);
expect(output.stdout).to.equal(expected);
});
});
});

function md2html(args, cwd) {
return new Promise((res) => {
execFile(
"node",
[`${resolve("./node_modules/@oai/build-infra/src/md2html/md2html.js")}`, ...args],
{ cwd },
(error, stdout, stderr) => {
res({
code: error?.code || 0,
error,
stdout,
stderr,
});
},
);
});
}
registerMd2htmlFixtureTests();
Loading
Loading