Skip to content

Commit 2228b49

Browse files
committed
test(oxa core): simplify minimal test examples
1 parent a184c2b commit 2228b49

File tree

2 files changed

+7
-36
lines changed

2 files changed

+7
-36
lines changed

packages/oxa-core/src/cli.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@ import { fileURLToPath } from "url";
88
const __dirname = dirname(fileURLToPath(import.meta.url));
99
const CLI_PATH = join(__dirname, "..", "dist", "cli.js");
1010

11-
// Valid minimal document
11+
// Valid minimal document (only required fields)
1212
const validDocument = {
1313
type: "Document",
14-
metadata: {},
15-
title: [{ type: "Text", value: "Hello", classes: [], data: {} }],
1614
children: [],
1715
};
1816

1917
const validYaml = `type: Document
20-
metadata: {}
21-
title:
22-
- type: Text
23-
value: Hello
24-
classes: []
25-
data: {}
2618
children: []
2719
`;
2820

@@ -148,9 +140,7 @@ describe("oxa validate", () => {
148140
const heading = {
149141
type: "Heading",
150142
level: 1,
151-
classes: [],
152-
data: {},
153-
children: [{ type: "Text", value: "Title", classes: [], data: {} }],
143+
children: [{ type: "Text", value: "Title" }],
154144
};
155145
const { exitCode } = await execa(
156146
"node",

packages/oxa-core/src/validate.test.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,21 @@ import {
1111
getTypeNames,
1212
} from "./validate.js";
1313

14-
// Valid minimal document
14+
// Valid minimal document (only required fields)
1515
const validDocument = {
1616
type: "Document",
17-
metadata: {},
18-
title: [{ type: "Text", value: "Hello", classes: [], data: {} }],
1917
children: [],
2018
};
2119

22-
// Valid document with content
20+
// Valid document with content (using minimal nested objects)
2321
const validDocumentWithContent = {
2422
type: "Document",
2523
metadata: { author: "Test" },
26-
title: [{ type: "Text", value: "Test Document", classes: [], data: {} }],
24+
title: [{ type: "Text", value: "Test Document" }],
2725
children: [
2826
{
2927
type: "Paragraph",
30-
classes: [],
31-
data: {},
32-
children: [{ type: "Text", value: "Hello world", classes: [], data: {} }],
28+
children: [{ type: "Text", value: "Hello world" }],
3329
},
3430
],
3531
};
@@ -51,7 +47,6 @@ describe("validate", () => {
5147
const result = validate({ type: "Document" });
5248
expect(result.valid).toBe(false);
5349
expect(result.errors.length).toBeGreaterThan(0);
54-
expect(result.errors.some((e) => e.message.includes("title"))).toBe(true);
5550
expect(result.errors.some((e) => e.message.includes("children"))).toBe(
5651
true,
5752
);
@@ -74,9 +69,7 @@ describe("validate", () => {
7469
const heading = {
7570
type: "Heading",
7671
level: 1,
77-
classes: [],
78-
data: {},
79-
children: [{ type: "Text", value: "Title", classes: [], data: {} }],
72+
children: [{ type: "Text", value: "Title" }],
8073
};
8174
const result = validate(heading, { type: "Heading" });
8275
expect(result.valid).toBe(true);
@@ -122,12 +115,6 @@ describe("validateYaml", () => {
122115
it("returns valid for correct YAML", () => {
123116
const yaml = `
124117
type: Document
125-
metadata: {}
126-
title:
127-
- type: Text
128-
value: Hello
129-
classes: []
130-
data: {}
131118
children: []
132119
`;
133120
const result = validateYaml(yaml);
@@ -163,12 +150,6 @@ describe("validateFile", () => {
163150
writeFileSync(
164151
yamlFile,
165152
`type: Document
166-
metadata: {}
167-
title:
168-
- type: Text
169-
value: Hello
170-
classes: []
171-
data: {}
172153
children: []
173154
`,
174155
);

0 commit comments

Comments
 (0)