File tree Expand file tree Collapse file tree 3 files changed +64
-6
lines changed Expand file tree Collapse file tree 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 {
106106
107107 // merge content and tutorial
108108 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 ) => {
111111 const levelContent = mdContent . levels [ level . id ] ;
112112
113113 if ( ! levelContent ) {
114- console . log ( `Markdown content not found for ${ level . id } ` ) ;
115- return ;
114+ return null ;
116115 }
117116
118117 level = { ...level , ...levelContent } ;
@@ -164,8 +163,8 @@ export function parse(params: ParseParams): any {
164163 ) ;
165164
166165 return level ;
167- }
168- ) ;
166+ } )
167+ . filter ( ( l : T . Level | null ) => ! ! l ) ;
169168 }
170169
171170 return parsed ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export function validateSchema(json: any): boolean | PromiseLike<boolean> {
1515
1616 if ( ! valid ) {
1717 // log errors
18+ /* istanbul ignore next */
1819 if ( process . env . NODE_ENV !== "test" ) {
1920 jsonSchema . errors ?. forEach ( ( error : JsonSchema . ErrorObject ) => {
2021 console . warn (
Original file line number Diff line number Diff line change @@ -609,6 +609,64 @@ The third step
609609 expect ( result . levels ) . toEqual ( expected . levels ) ;
610610 } ) ;
611611
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+
612670 // config
613671 it ( "should parse the tutorial config" , ( ) => {
614672 const md = `# Title
You can’t perform that action at this time.
0 commit comments