File tree Expand file tree Collapse file tree 2 files changed +67
-15
lines changed Expand file tree Collapse file tree 2 files changed +67
-15
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,22 @@ page_task
71
71
= '+'
72
72
space ?
73
73
description : description
74
- tests : task_test *
75
- hints : task_hint *
74
+ actions : task_actions *
76
75
break ?
77
76
78
- { return { description, tests, hints }; }
77
+ { let task = { description, tests: [], hints: [] };
78
+ actions .forEach (({type, value}) => task[type].push (value));
79
+ return task;
80
+ }
81
+
82
+ page_actions
83
+ = page_onComplete
84
+ / page_import
85
+
86
+ task_actions
87
+ = test : task_test
88
+ / hint : task_hint
89
+ / action : task_action
79
90
80
91
info_title
81
92
= '#'
@@ -95,15 +106,6 @@ description
95
106
break
96
107
{ return adjust (description); }
97
108
98
- page_actions
99
- = page_onComplete
100
- / page_import
101
-
102
- task_actions
103
- = task_test
104
- / task_hint
105
- / task_action
106
-
107
109
task_test
108
110
= '@test'
109
111
'('
@@ -112,13 +114,15 @@ task_test
112
114
quote
113
115
')'
114
116
break
115
- { return testPath .join (' ' ); }
117
+ { return { type : ' tests ' , value : testPath .join (' ' ) } ; }
116
118
117
119
task_hint
118
120
= '@hint'
119
121
hint : [^\n ^\r ]+
120
122
break
121
- { return trimBracketsAndQuotes (hint .join (' ' )); }
123
+ { let h = trimBracketsAndQuotes (hint .join (' ' ));
124
+ return { type: ' hints' , value: h };
125
+ }
122
126
123
127
task_action
124
128
= '@action'
@@ -136,7 +140,7 @@ page_import
136
140
break
137
141
{ return filePath .join (' ' ); }
138
142
139
-
143
+
140
144
// characters
141
145
142
146
content = [^#^@^+] [^\n ^\r ]+ [\n\r ]
Original file line number Diff line number Diff line change @@ -46,3 +46,51 @@ description
46
46
const result = parse ( data ) ;
47
47
t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
48
48
} ) ;
49
+
50
+ test ( 'parses a task hint before a test' , t => {
51
+ const data = `# Title
52
+ description
53
+
54
+ ## Page One
55
+ description
56
+
57
+ + Task One
58
+ @test('01, 02')
59
+ @hint('do something')
60
+ ` ;
61
+ const expected = [ {
62
+ description : 'Task One' ,
63
+ tests : [
64
+ '01, 02'
65
+ ] ,
66
+ hints : [
67
+ 'do something'
68
+ ]
69
+ } ] ;
70
+ const result = parse ( data ) ;
71
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
72
+ } ) ;
73
+
74
+ test ( 'parses a task test before a hint' , t => {
75
+ const data = `# Title
76
+ description
77
+
78
+ ## Page One
79
+ description
80
+
81
+ + Task One
82
+ @hint('do something')
83
+ @test('01, 02')
84
+ ` ;
85
+ const expected = [ {
86
+ description : 'Task One' ,
87
+ tests : [
88
+ '01, 02'
89
+ ] ,
90
+ hints : [
91
+ 'do something'
92
+ ]
93
+ } ] ;
94
+ const result = parse ( data ) ;
95
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
96
+ } ) ;
You can’t perform that action at this time.
0 commit comments