@@ -19,7 +19,7 @@ describe("parse", () => {
19
19
expect ( result . summary ) . toEqual ( expected . summary ) ;
20
20
} ) ;
21
21
22
- it ( "should parse a level with a summary " , ( ) => {
22
+ it ( "should parse a level with no steps " , ( ) => {
23
23
const md = `# Title
24
24
25
25
Description.
@@ -49,4 +49,99 @@ levels:
49
49
} ;
50
50
expect ( result . levels ) . toEqual ( expected . levels ) ;
51
51
} ) ;
52
+
53
+ it ( "should parse a level with a step" , ( ) => {
54
+ const md = `# Title
55
+
56
+ Description.
57
+
58
+ ## L1 Put Level's title here
59
+
60
+ > Level's summary: a short description of the level's content in one line.
61
+
62
+ Some text
63
+ ` ;
64
+
65
+ const yaml = `version: "0.1.0"
66
+ levels:
67
+ - id: L1
68
+ setup:
69
+ files: []
70
+ commits: []
71
+ solution:
72
+ files: []
73
+ commits: []
74
+ ` ;
75
+ const result = parse ( md , yaml ) ;
76
+ const expected = {
77
+ levels : [
78
+ {
79
+ id : "L1" ,
80
+ title : "Put Level's title here" ,
81
+ summary :
82
+ "Level's summary: a short description of the level's content in one line." ,
83
+ content : "Some text" ,
84
+ setup : { files : [ ] , commits : [ ] } ,
85
+ solution : { files : [ ] , commits : [ ] } ,
86
+ } ,
87
+ ] ,
88
+ } ;
89
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
90
+ } ) ;
91
+
92
+ it ( "should parse a level with no level description" , ( ) => {
93
+ const md = `# Title
94
+
95
+ Description.
96
+
97
+ ## L1 Put Level's title here
98
+
99
+ Some text that becomes the summary
100
+ ` ;
101
+
102
+ const yaml = `version: "0.1.0"
103
+ levels:
104
+ - id: L1
105
+ ` ;
106
+ const result = parse ( md , yaml ) ;
107
+ const expected = {
108
+ levels : [
109
+ {
110
+ id : "L1" ,
111
+ title : "Put Level's title here" ,
112
+ summary : "Some text that becomes the summary" ,
113
+ content : "Some text that becomes the summary" ,
114
+ } ,
115
+ ] ,
116
+ } ;
117
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
118
+ } ) ;
119
+
120
+ it ( "should truncate a level description" , ( ) => {
121
+ const md = `# Title
122
+
123
+ Description.
124
+
125
+ ## L1 Put Level's title here
126
+
127
+ Some text that becomes the summary and goes beyond the maximum length of 80 so that it gets truncated at the end
128
+ ` ;
129
+
130
+ const yaml = `version: "0.1.0"
131
+ levels:
132
+ - id: L1
133
+ ` ;
134
+ const result = parse ( md , yaml ) ;
135
+ const expected = {
136
+ levels : [
137
+ {
138
+ id : "L1" ,
139
+ title : "Put Level's title here" ,
140
+ summary : "Some text that becomes the summary" ,
141
+ content : "Some text that becomes the summary" ,
142
+ } ,
143
+ ] ,
144
+ } ;
145
+ expect ( result . levels [ 0 ] . summary ) . toMatch ( / \. \. \. $ / ) ;
146
+ } ) ;
52
147
} ) ;
0 commit comments