@@ -11,25 +11,21 @@ import {
1111 getTypeNames ,
1212} from "./validate.js" ;
1313
14- // Valid minimal document
14+ // Valid minimal document (only required fields)
1515const 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)
2321const 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 = `
124117type: Document
125- metadata: {}
126- title:
127- - type: Text
128- value: Hello
129- classes: []
130- data: {}
131118children: []
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: {}
172153children: []
173154` ,
174155 ) ;
0 commit comments