11import { parse } from "../src/utils/parse" ;
22
33describe ( "parse" , ( ) => {
4+ // summary
45 it ( "should parse summary" , ( ) => {
56 const md = `# Insert Tutorial's Title here
67
@@ -23,6 +24,7 @@ describe("parse", () => {
2324 expect ( result . summary ) . toEqual ( expected . summary ) ;
2425 } ) ;
2526
27+ // levels
2628 it ( "should parse a level with no steps" , ( ) => {
2729 const md = `# Title
2830
@@ -52,6 +54,7 @@ Some text
5254 summary :
5355 "Level's summary: a short description of the level's content in one line." ,
5456 content : "Some text" ,
57+ steps : [ ] ,
5558 } ,
5659 ] ,
5760 } ;
@@ -76,6 +79,7 @@ Some text
7679 id : "L1" ,
7780 setup : { files : [ ] , commits : [ ] } ,
7881 solution : { files : [ ] , commits : [ ] } ,
82+ steps : [ ] ,
7983 } ,
8084 ] ,
8185 } ;
@@ -94,6 +98,7 @@ Some text
9498 content : "Some text" ,
9599 setup : { files : [ ] , commits : [ ] } ,
96100 solution : { files : [ ] , commits : [ ] } ,
101+ steps : [ ] ,
97102 } ,
98103 ] ,
99104 } ;
@@ -123,6 +128,7 @@ Some text that becomes the summary
123128 title : "Put Level's title here" ,
124129 summary : "Some text that becomes the summary" ,
125130 content : "Some text that becomes the summary" ,
131+ steps : [ ] ,
126132 } ,
127133 ] ,
128134 } ;
@@ -196,31 +202,168 @@ Third line
196202 expect ( result . levels [ 0 ] . content ) . toBe ( expected . levels [ 0 ] . content ) ;
197203 } ) ;
198204
199- it ( "should parse the tutorial config" , ( ) => {
205+ it ( "should load a single commit for a step" , ( ) => {
206+ const md = `# Title
207+
208+ Description.
209+
210+ ## L1 Title
211+
212+ First line
213+
214+ ### L1S1 Step
215+
216+ The first step
217+ ` ;
218+ const config = {
219+ levels : [
220+ {
221+ id : "L1" ,
222+ steps : [
223+ {
224+ id : "L1S1" ,
225+ } ,
226+ ] ,
227+ } ,
228+ ] ,
229+ } ;
230+ const result = parse ( {
231+ text : md ,
232+ config,
233+ commits : {
234+ L1S1Q : [ "abcdefg1" ] ,
235+ } ,
236+ } ) ;
237+ const expected = {
238+ summary : {
239+ description : "Description." ,
240+ } ,
241+ levels : [
242+ {
243+ id : "L1" ,
244+ summary : "First line" ,
245+ content : "First line" ,
246+ steps : [
247+ {
248+ id : "L1S1" ,
249+ content : "The first step" ,
250+ setup : {
251+ commits : [ "abcdefg1" ] ,
252+ } ,
253+ } ,
254+ ] ,
255+ } ,
256+ ] ,
257+ } ;
258+ expect ( result . levels [ 0 ] . steps [ 0 ] ) . toEqual ( expected . levels [ 0 ] . steps [ 0 ] ) ;
259+ } ) ;
260+
261+ it ( "should load multiple commits for a step" , ( ) => {
200262 const md = `# Title
201263
202264Description.
265+
266+ ## L1 Title
267+
268+ First line
269+
270+ ### L1S1 Step
271+
272+ The first step
203273` ;
204- const yaml = `
205- config:
206- testRunner:
207- command: ./node_modules/.bin/mocha
208- args:
209- filter: --grep
210- tap: --reporter=mocha-tap-reporter
211- directory: coderoad
212- setup:
213- commits:
214- - abcdefg1
215- commands: []
216- appVersions:
217- vscode: '>=0.7.0'
218- repo:
219- uri: https://path.to/repo
220- branch: aBranch
221- dependencies:
222- - name: node
223- version: '>=10'
274+ const config = {
275+ levels : [
276+ {
277+ id : "L1" ,
278+ steps : [
279+ {
280+ id : "L1S1" ,
281+ } ,
282+ ] ,
283+ } ,
284+ ] ,
285+ } ;
286+ const result = parse ( {
287+ text : md ,
288+ config,
289+ commits : {
290+ L1S1Q : [ "abcdefg1" , "123456789" ] ,
291+ } ,
292+ } ) ;
293+ const expected = {
294+ summary : {
295+ description : "Description." ,
296+ } ,
297+ levels : [
298+ {
299+ id : "L1" ,
300+ summary : "First line" ,
301+ content : "First line" ,
302+ steps : [
303+ {
304+ id : "L1S1" ,
305+ content : "The first step" ,
306+ setup : {
307+ commits : [ "abcdefg1" , "123456789" ] ,
308+ } ,
309+ } ,
310+ ] ,
311+ } ,
312+ ] ,
313+ } ;
314+ expect ( result . levels [ 0 ] . steps [ 0 ] ) . toEqual ( expected . levels [ 0 ] . steps [ 0 ] ) ;
315+ } ) ;
316+
317+ it ( "should load a single commit for a level" , ( ) => {
318+ const md = `# Title
319+
320+ Description.
321+
322+ ## L1 Title
323+
324+ First line
325+
326+ ### L1S1
327+
328+ The first step
329+ ` ;
330+ const config = {
331+ levels : [
332+ {
333+ id : "L1" ,
334+ } ,
335+ ] ,
336+ } ;
337+ const result = parse ( {
338+ text : md ,
339+ config,
340+ commits : {
341+ L1 : [ "abcdefg1" ] ,
342+ } ,
343+ } ) ;
344+ const expected = {
345+ summary : {
346+ description : "Description." ,
347+ } ,
348+ levels : [
349+ {
350+ id : "L1" ,
351+ summary : "First line" ,
352+ content : "First line" ,
353+ setup : {
354+ commits : [ "abcdefg1" ] ,
355+ } ,
356+ } ,
357+ ] ,
358+ } ;
359+ expect ( result . levels [ 0 ] . setup ) . toEqual ( expected . levels [ 0 ] . setup ) ;
360+ } ) ;
361+
362+ // config
363+ it ( "should parse the tutorial config" , ( ) => {
364+ const md = `# Title
365+
366+ Description.
224367` ;
225368
226369 const config = {
0 commit comments