Skip to content

Commit afb983a

Browse files
authored
Merge pull request #136 from ethdebug/format-tests
Get rid of tests package and just use @ethdebug/format
2 parents dac663c + d1f6bd4 commit afb983a

File tree

13 files changed

+33
-83
lines changed

13 files changed

+33
-83
lines changed

packages/format/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@
2222
"yaml": "^2.3.4"
2323
},
2424
"devDependencies": {
25+
"@hyperjump/browser": "^1.2.0",
26+
"@hyperjump/json-schema": "^1.11.0",
2527
"chalk": "^4.1.0",
28+
"cli-highlight": "^2.1.11",
2629
"concurrently": "^8.2.2",
30+
"indent-string": "^4.0.0",
2731
"nodemon": "^3.0.2",
2832
"ts-node": "^10.9.2",
2933
"typescript": "^5.3.3",

packages/tests/schemas/examples.test.ts renamed to packages/format/src/schemas/examples.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect, describe, it } from "vitest";
22

3-
import type { JSONSchema } from "@ethdebug/format";
4-
5-
import schemas, { schemaExtensions } from "../src/schemas.js";
3+
import { schemaExtensions } from "../../test/extensions";
4+
import { schemas } from ".";
5+
import type { JSONSchema } from "../describe";
66

77
// loads schemas into global hyperjump json schema validator
8-
import "../src/loadSchemas.js";
8+
import "../../test/hyperjump";
99

1010
const idsOfSchemasAllowedToOmitExamples = new Set([
1111
"schema:ethdebug/format/type",

packages/tests/schemas/validity.test.ts renamed to packages/format/src/schemas/validity.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { describe, it } from "vitest";
22
import {
3+
type OutputUnit,
34
validate,
45
InvalidSchemaError,
56
} from "@hyperjump/json-schema/draft-2020-12";
67

7-
import schemas from "../src/schemas.js";
8-
import printErrors from "../src/printErrors.js";
8+
import { schemas } from ".";
99

1010
// loads schemas into global hyperjump json schema validator
11-
import "../src/loadSchemas.js";
11+
import "../../test/hyperjump";
12+
13+
const printErrors = (output: OutputUnit): string => output.errors!
14+
.map((error) => {
15+
if (!error.valid && !error.keyword.endsWith("#validate")) {
16+
return `${
17+
error.instanceLocation
18+
} fails schema constraint ${
19+
error.absoluteKeywordLocation
20+
}`;
21+
}
22+
})
23+
.filter((message): message is string => !!message)
24+
.map(message => ` - ${message}`)
25+
.join("\n");
1226

1327
describe("Valid schemas", () => {
1428
for (const [id, schema] of Object.entries(schemas)) {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { schemas } from "@ethdebug/format";
1+
import { schemas } from "../src";
22

33
export const schemaExtensions: {
44
[schemaId: string]: {
@@ -81,5 +81,3 @@ export const schemaExtensions: {
8181
extends: new Set(["schema:ethdebug/format/type/complex"])
8282
},
8383
}
84-
85-
export default schemas;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import {
44
validate,
55
setMetaSchemaOutputFormat,
66
} from "@hyperjump/json-schema/draft-2020-12";
7+
// @ts-ignore
78
import { BASIC } from "@hyperjump/json-schema/experimental";
89
import { bundle } from "@hyperjump/json-schema/bundle";
9-
import YAML from "yaml";
10+
import * as YAML from "yaml";
1011
import indentString from "indent-string";
1112
import { highlight } from "cli-highlight";
1213

1314
import {
1415
describeSchema,
1516
type DescribeSchemaOptions
16-
} from "@ethdebug/format";
17+
} from "../src/describe";
1718

18-
import schemas from "./schemas.js";
19+
import { schemas } from "../src/schemas";
1920

2021
const main = () => {
2122
setMetaSchemaOutputFormat(BASIC);

packages/format/vitest.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import "vitest";
2+
import type { DescribeSchemaOptions } from "./src/describe";
23

34
interface CustomMatchers<R = unknown> {
5+
toValidate(schemaOptions: DescribeSchemaOptions): R;
6+
47
toSatisfy(received: any): R;
58
toSatisfyAll(values: readonly any[]): R;
69
}

packages/tests/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/tests/package.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/tests/src/printErrors.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/tests/tsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)