@@ -37,7 +37,8 @@ const validJson: Partial<T.Tutorial> = {
3737 {
3838 id : "1.1" ,
3939 content : "The first step" ,
40- setup : { commits : [ ] } ,
40+ setup : { commits : [ "abcdefa" ] } ,
41+ solution : { commits : [ "abcdefb" ] } ,
4142 } ,
4243 ] ,
4344 } ,
@@ -74,4 +75,60 @@ describe("validate tutorial", () => {
7475 const valid = validateTutorial ( json ) ;
7576 expect ( valid ) . toBe ( true ) ;
7677 } ) ;
78+ it ( "should allow a step with no solution" , ( ) => {
79+ const json = {
80+ ...validJson ,
81+ levels : [
82+ {
83+ id : "1" ,
84+ title : "Level 1" ,
85+ summary : "summary" ,
86+ content : "content" ,
87+ steps : [
88+ {
89+ id : "1.1" ,
90+ content : "The first step" ,
91+ setup : { commits : [ "abcdefa" ] } ,
92+ } ,
93+ {
94+ id : "1.2" ,
95+ content : "The second step" ,
96+ setup : { commits : [ "abcdefb" ] } ,
97+ } ,
98+ ] ,
99+ } ,
100+ ] ,
101+ } ;
102+
103+ const valid = validateTutorial ( json ) ;
104+ expect ( valid ) . toBe ( true ) ;
105+ } ) ;
106+ it ( "shouldn't allow a step with no setup but a solution" , ( ) => {
107+ const json = {
108+ ...validJson ,
109+ levels : [
110+ {
111+ id : "1" ,
112+ title : "Level 1" ,
113+ summary : "summary" ,
114+ content : "content" ,
115+ steps : [
116+ {
117+ id : "1.1" ,
118+ content : "The first step" ,
119+ solution : { commits : [ "abcdefa" ] } ,
120+ } ,
121+ {
122+ id : "1.2" ,
123+ content : "The second step" ,
124+ solution : { commits : [ "abcdefb" ] } ,
125+ } ,
126+ ] ,
127+ } ,
128+ ] ,
129+ } ;
130+
131+ const valid = validateTutorial ( json ) ;
132+ expect ( valid ) . toBe ( false ) ;
133+ } ) ;
77134} ) ;
0 commit comments