1
1
import { parse } from "../src/utils/parse" ;
2
2
3
3
describe ( "parse" , ( ) => {
4
+ // summary
4
5
it ( "should parse summary" , ( ) => {
5
6
const md = `# Insert Tutorial's Title here
6
7
@@ -23,6 +24,7 @@ describe("parse", () => {
23
24
expect ( result . summary ) . toEqual ( expected . summary ) ;
24
25
} ) ;
25
26
27
+ // levels
26
28
it ( "should parse a level with no steps" , ( ) => {
27
29
const md = `# Title
28
30
@@ -52,6 +54,7 @@ Some text
52
54
summary :
53
55
"Level's summary: a short description of the level's content in one line." ,
54
56
content : "Some text" ,
57
+ steps : [ ] ,
55
58
} ,
56
59
] ,
57
60
} ;
@@ -76,6 +79,7 @@ Some text
76
79
id : "L1" ,
77
80
setup : { files : [ ] , commits : [ ] } ,
78
81
solution : { files : [ ] , commits : [ ] } ,
82
+ steps : [ ] ,
79
83
} ,
80
84
] ,
81
85
} ;
@@ -94,6 +98,7 @@ Some text
94
98
content : "Some text" ,
95
99
setup : { files : [ ] , commits : [ ] } ,
96
100
solution : { files : [ ] , commits : [ ] } ,
101
+ steps : [ ] ,
97
102
} ,
98
103
] ,
99
104
} ;
@@ -123,6 +128,7 @@ Some text that becomes the summary
123
128
title : "Put Level's title here" ,
124
129
summary : "Some text that becomes the summary" ,
125
130
content : "Some text that becomes the summary" ,
131
+ steps : [ ] ,
126
132
} ,
127
133
] ,
128
134
} ;
@@ -196,31 +202,168 @@ Third line
196
202
expect ( result . levels [ 0 ] . content ) . toBe ( expected . levels [ 0 ] . content ) ;
197
203
} ) ;
198
204
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" , ( ) => {
200
262
const md = `# Title
201
263
202
264
Description.
265
+
266
+ ## L1 Title
267
+
268
+ First line
269
+
270
+ ### L1S1 Step
271
+
272
+ The first step
203
273
` ;
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.
224
367
` ;
225
368
226
369
const config = {
0 commit comments