Skip to content

Commit 1f2a389

Browse files
committed
Prettier
1 parent ff0fdec commit 1f2a389

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

scripts/schema-test-coverage.mjs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { join } from "node:path";
44
import { argv } from "node:process";
55
import "@hyperjump/json-schema/draft-2020-12";
66
import "@hyperjump/json-schema/draft-04";
7-
import { compile, getSchema, interpret, Validation, BASIC } from "@hyperjump/json-schema/experimental";
7+
import {
8+
compile,
9+
getSchema,
10+
interpret,
11+
Validation,
12+
BASIC,
13+
} from "@hyperjump/json-schema/experimental";
814
import * as Instance from "@hyperjump/json-schema/instance/experimental";
915

1016
/**
@@ -18,18 +24,24 @@ import { buildSchemaDocument } from "@hyperjump/json-schema/experimental";
1824

1925
addMediaTypePlugin("application/schema+yaml", {
2026
parse: async (response) => {
21-
const contentType = contentTypeParser.parse(response.headers.get("content-type") ?? "");
22-
const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile;
27+
const contentType = contentTypeParser.parse(
28+
response.headers.get("content-type") ?? "",
29+
);
30+
const contextDialectId =
31+
contentType.parameters.schema ?? contentType.parameters.profile;
2332

2433
const foo = YAML.parse(await response.text());
2534
return buildSchemaDocument(foo, response.url, contextDialectId);
2635
},
27-
fileMatcher: (path) => path.endsWith(".yaml")
36+
fileMatcher: (path) => path.endsWith(".yaml"),
2837
});
2938

3039
/** @type (testDirectory: string) => AsyncGenerator<[string,Json]> */
3140
const tests = async function* (testDirectory) {
32-
for (const file of await readdir(testDirectory, { recursive: true, withFileTypes: true })) {
41+
for (const file of await readdir(testDirectory, {
42+
recursive: true,
43+
withFileTypes: true,
44+
})) {
3345
if (!file.isFile() || !file.name.endsWith(".yaml")) {
3446
continue;
3547
}
@@ -100,12 +112,21 @@ Validation.interpret = baseInterpret;
100112
// console.log("Covered:", visitedLocations);
101113

102114
const allKeywords = keywordLocations(compiled.ast);
103-
const notCovered = allKeywords.filter((location) => !visitedLocations.has(location));
104-
console.log("NOT Covered:", notCovered.length, "of", allKeywords.length,);
105-
106-
const maxNotCovered = 20;
107-
const firstNotCovered = notCovered.slice(0, maxNotCovered);
108-
if (notCovered.length > maxNotCovered) firstNotCovered.push("...");
109-
console.log(firstNotCovered);
110-
111-
console.log("Covered:", visitedLocations.size, "of", allKeywords.length, "(" + Math.floor(visitedLocations.size / allKeywords.length * 100) + "%)");
115+
const notCovered = allKeywords.filter(
116+
(location) => !visitedLocations.has(location),
117+
);
118+
if (notCovered.length > 0) {
119+
console.log("NOT Covered:", notCovered.length, "of", allKeywords.length);
120+
const maxNotCovered = 20;
121+
const firstNotCovered = notCovered.slice(0, maxNotCovered);
122+
if (notCovered.length > maxNotCovered) firstNotCovered.push("...");
123+
console.log(firstNotCovered);
124+
}
125+
126+
console.log(
127+
"Covered:",
128+
visitedLocations.size,
129+
"of",
130+
allKeywords.length,
131+
"(" + Math.floor((visitedLocations.size / allKeywords.length) * 100) + "%)",
132+
);

0 commit comments

Comments
 (0)