File tree 3 files changed +64
-6
lines changed
3 files changed +64
-6
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,12 @@ export function parse(params: ParseParams): any {
106
106
107
107
// merge content and tutorial
108
108
if ( params . config . levels && params . config . levels . length ) {
109
- parsed . levels = params . config . levels . map (
110
- ( level : T . Level , levelIndex : number ) => {
109
+ parsed . levels = params . config . levels
110
+ . map ( ( level : T . Level , levelIndex : number ) => {
111
111
const levelContent = mdContent . levels [ level . id ] ;
112
112
113
113
if ( ! levelContent ) {
114
- console . log ( `Markdown content not found for ${ level . id } ` ) ;
115
- return ;
114
+ return null ;
116
115
}
117
116
118
117
level = { ...level , ...levelContent } ;
@@ -164,8 +163,8 @@ export function parse(params: ParseParams): any {
164
163
) ;
165
164
166
165
return level ;
167
- }
168
- ) ;
166
+ } )
167
+ . filter ( ( l : T . Level | null ) => ! ! l ) ;
169
168
}
170
169
171
170
return parsed ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export function validateSchema(json: any): boolean | PromiseLike<boolean> {
15
15
16
16
if ( ! valid ) {
17
17
// log errors
18
+ /* istanbul ignore next */
18
19
if ( process . env . NODE_ENV !== "test" ) {
19
20
jsonSchema . errors ?. forEach ( ( error : JsonSchema . ErrorObject ) => {
20
21
console . warn (
Original file line number Diff line number Diff line change @@ -609,6 +609,64 @@ The third step
609
609
expect ( result . levels ) . toEqual ( expected . levels ) ;
610
610
} ) ;
611
611
612
+ it ( "should handle steps with no solution" , ( ) => {
613
+ const md = `# Title
614
+
615
+ Description.
616
+
617
+ ## L1 Title 1
618
+
619
+ First level content.
620
+
621
+ ### L1S1
622
+
623
+ The first step
624
+
625
+ ` ;
626
+ const config = {
627
+ levels : [
628
+ {
629
+ id : "L1" ,
630
+ steps : [
631
+ {
632
+ id : "L1S1" ,
633
+ } ,
634
+ ] ,
635
+ } ,
636
+ ] ,
637
+ } ;
638
+ const result = parse ( {
639
+ text : md ,
640
+ config,
641
+ commits : {
642
+ L1S1Q : [ "abcdefg1" , "123456789" ] ,
643
+ } ,
644
+ } ) ;
645
+ const expected = {
646
+ summary : {
647
+ description : "Description." ,
648
+ } ,
649
+ levels : [
650
+ {
651
+ id : "L1" ,
652
+ title : "Title 1" ,
653
+ summary : "First level content." ,
654
+ content : "First level content." ,
655
+ steps : [
656
+ {
657
+ id : "L1S1" ,
658
+ content : "The first step" ,
659
+ setup : {
660
+ commits : [ "abcdefg1" , "123456789" ] ,
661
+ } ,
662
+ } ,
663
+ ] ,
664
+ } ,
665
+ ] ,
666
+ } ;
667
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
668
+ } ) ;
669
+
612
670
// config
613
671
it ( "should parse the tutorial config" , ( ) => {
614
672
const md = `# Title
You can’t perform that action at this time.
0 commit comments