File tree Expand file tree Collapse file tree 7 files changed +253
-16
lines changed Expand file tree Collapse file tree 7 files changed +253
-16
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
+ npm-debug.log
Original file line number Diff line number Diff line change 7
7
"author" : " Shawn McKay <shawn.j.mckay@gmail.com>" ,
8
8
"main" : " parser/index.pegjs" ,
9
9
"scripts" : {
10
- "test" : " ava"
10
+ "test" : " ava" ,
11
+ "test:watch" : " ava --watch"
11
12
},
12
13
"dependencies" : {
13
14
"pegjs" : " ^0.9.0" ,
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ test('parses a description', t => {
21
21
const data = `# Title
22
22
some description
23
23
` ;
24
- console . log ( data ) ;
25
24
const expected = {
26
25
info : {
27
26
title : 'Title' ,
@@ -38,7 +37,6 @@ some description
38
37
and more on
39
38
the next line
40
39
` ;
41
- console . log ( data ) ;
42
40
const expected = {
43
41
info : {
44
42
title : 'Title' ,
@@ -58,7 +56,6 @@ test.skip('parses a title after empty spaces', t => {
58
56
# Title
59
57
some description
60
58
` ;
61
- console . log ( data ) ;
62
59
const expected = {
63
60
info : {
64
61
title : 'Title' ,
Original file line number Diff line number Diff line change @@ -5,9 +5,55 @@ import { readFileSync } from 'fs';
5
5
const parser = readFileSync ( '../parser/index.pegjs' , 'utf8' ) ;
6
6
const parse = pegjs . buildParser ( parser ) . parse ;
7
7
8
- test . todo ( 'parses a page title' ) ;
9
- test . todo ( 'parses a page with empty description' ) ;
10
- test . todo ( 'parses two pages' ) ;
8
+ test ( 'parses a page title' , t => {
9
+ const data = `# Title
10
+ description
11
+
12
+ ## Page One
13
+ ` ;
14
+ const expected = [ {
15
+ title : 'Page One' ,
16
+ description : ''
17
+ } ] ;
18
+ const result = parse ( data ) ;
19
+ t . deepEqual ( result . pages , expected ) ;
20
+ } ) ;
21
+
22
+ test ( 'parses a page with empty description' , t => {
23
+ const data = `# Title
24
+ description
25
+
26
+ ## Page One
27
+ page one description
28
+ ` ;
29
+ const expected = [ {
30
+ title : 'Page One' ,
31
+ description : 'page one description'
32
+ } ] ;
33
+ const result = parse ( data ) ;
34
+ t . deepEqual ( result . pages , expected ) ;
35
+ } ) ;
36
+
37
+ test ( 'parses two pages' , t => {
38
+ const data = `# Title
39
+ description
40
+
41
+ ## Page One
42
+ page one description
43
+
44
+ ## Page Two
45
+ page two description
46
+ ` ;
47
+ const expected = [ {
48
+ title : 'Page One' ,
49
+ description : 'page one description'
50
+ } , {
51
+ title : 'Page Two' ,
52
+ description : 'page two description'
53
+ } ] ;
54
+ const result = parse ( data ) ;
55
+ t . deepEqual ( result . pages , expected ) ;
56
+ } ) ;
11
57
12
58
test . todo ( 'parses an onPageComplete' ) ;
13
59
test . todo ( 'throws when multiple onPageCompletes' ) ;
Original file line number Diff line number Diff line change
1
+ import test from 'ava' ;
2
+ import pegjs from 'pegjs' ;
3
+ import { readFileSync } from 'fs' ;
4
+
5
+ const parser = readFileSync ( '../parser/index.pegjs' , 'utf8' ) ;
6
+ const parse = pegjs . buildParser ( parser ) . parse ;
7
+
8
+ test ( 'parses a task hint' , t => {
9
+ const data = `# Title
10
+ description
11
+
12
+ ## Page One
13
+ description
14
+
15
+ + Task One
16
+ @test('01, 02')
17
+ @hint('do something')
18
+ ` ;
19
+ const expected = [ {
20
+ description : 'Task One' ,
21
+ tests : [
22
+ '01, 02'
23
+ ] ,
24
+ hints : [
25
+ 'do something'
26
+ ]
27
+ } ] ;
28
+ const result = parse ( data ) ;
29
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
30
+ } ) ;
31
+
32
+ test ( 'parses multiple task hints' , t => {
33
+ const data = `# Title
34
+ description
35
+
36
+ ## Page One
37
+ description
38
+
39
+ + Task One
40
+ @test('01, 02')
41
+ @hint('do something')
42
+ @hint('do something else')
43
+ ` ;
44
+ const expected = [ {
45
+ description : 'Task One' ,
46
+ tests : [
47
+ '01, 02'
48
+ ] ,
49
+ hints : [
50
+ 'do something' ,
51
+ 'do something else'
52
+ ]
53
+ } ] ;
54
+ const result = parse ( data ) ;
55
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
56
+ } ) ;
57
+
58
+ test ( 'parses a task hint with quotes inside' , t => {
59
+ const data = `# Title
60
+ description
61
+
62
+ ## Page One
63
+ description
64
+
65
+ + Task One
66
+ @test('01, 02')
67
+ @hint('do \' " \` something')
68
+ ` ;
69
+ const expected = [ {
70
+ description : 'Task One' ,
71
+ tests : [
72
+ '01, 02'
73
+ ] ,
74
+ hints : [
75
+ 'do \' " \` something'
76
+ ]
77
+ } ] ;
78
+ const result = parse ( data ) ;
79
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
80
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import test from 'ava' ;
2
+ import pegjs from 'pegjs' ;
3
+ import { readFileSync } from 'fs' ;
4
+
5
+ const parser = readFileSync ( '../parser/index.pegjs' , 'utf8' ) ;
6
+ const parse = pegjs . buildParser ( parser ) . parse ;
7
+
8
+ test ( 'parses a task test' , t => {
9
+ const data = `# Title
10
+ description
11
+
12
+ ## Page One
13
+ description
14
+
15
+ + Task One
16
+ @test('01, 02')
17
+ ` ;
18
+ const expected = [ {
19
+ description : 'Task One' ,
20
+ tests : [
21
+ '01, 02'
22
+ ] ,
23
+ hints : [ ]
24
+ } ] ;
25
+ const result = parse ( data ) ;
26
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
27
+ } ) ;
28
+
29
+ test ( 'parses multiple task tests' , t => {
30
+ const data = `# Title
31
+ description
32
+
33
+ ## Page One
34
+ description
35
+
36
+ + Task One
37
+ @test('01, 02')
38
+ @test('03, 04')
39
+ ` ;
40
+ const expected = [ {
41
+ description : 'Task One' ,
42
+ tests : [
43
+ '01, 02' ,
44
+ '03, 04'
45
+ ] ,
46
+ hints : [ ]
47
+ } ] ;
48
+ const result = parse ( data ) ;
49
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
50
+ } ) ;
51
+
52
+ test ( 'parses task tests across pages' , t => {
53
+ const data = `# Title
54
+ description
55
+
56
+ ## Page One
57
+ description
58
+
59
+ + Task One
60
+ @test('01, 02')
61
+
62
+ + Task Two
63
+ @test('02, 01')
64
+ ` ;
65
+ const expected = [ {
66
+ description : 'Task One' ,
67
+ tests : [
68
+ '01, 02'
69
+ ] ,
70
+ hints : [ ]
71
+ } , {
72
+ description : 'Task Two' ,
73
+ tests : [
74
+ '02, 01'
75
+ ] ,
76
+ hints : [ ]
77
+ } ] ;
78
+ const result = parse ( data ) ;
79
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
80
+ } ) ;
81
+
82
+ test . todo ( 'warns when missing a task test' ) ;
Original file line number Diff line number Diff line change @@ -5,14 +5,44 @@ import { readFileSync } from 'fs';
5
5
const parser = readFileSync ( '../parser/index.pegjs' , 'utf8' ) ;
6
6
const parse = pegjs . buildParser ( parser ) . parse ;
7
7
8
- test . todo ( 'parses a task description' ) ;
9
- test . todo ( 'parses a second page with a task' ) ;
8
+ test ( 'parses a task description' , t => {
9
+ const data = `# Title
10
+ description
10
11
11
- test . todo ( 'parses a task test' ) ;
12
- test . todo ( 'warns when missing a task test' ) ;
13
- test . todo ( 'parses multiple task tests' ) ;
14
- test . todo ( 'parses task tests across pages' ) ;
12
+ ## Page One
13
+ description
15
14
16
- test . todo ( 'parses a task hint' ) ;
17
- test . todo ( 'parses multiple task hints' ) ;
18
- test . todo ( 'parses a task hint with single quote inside' ) ;
15
+ + Task One
16
+ ` ;
17
+ const expected = [ {
18
+ description : 'Task One' ,
19
+ tests : [ ] ,
20
+ hints : [ ]
21
+ } ] ;
22
+ const result = parse ( data ) ;
23
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
24
+ } ) ;
25
+
26
+ test ( 'parses a second page with a task' , t => {
27
+ const data = `# Title
28
+ description
29
+
30
+ ## Page One
31
+ description
32
+
33
+ + Task One
34
+
35
+ + Task Two
36
+ ` ;
37
+ const expected = [ {
38
+ description : 'Task One' ,
39
+ tests : [ ] ,
40
+ hints : [ ]
41
+ } , {
42
+ description : 'Task Two' ,
43
+ tests : [ ] ,
44
+ hints : [ ]
45
+ } ] ;
46
+ const result = parse ( data ) ;
47
+ t . deepEqual ( result . pages [ 0 ] . tasks , expected ) ;
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments