|
1 |
| -varexpect=require('chai').expect; |
2 |
| -vartask=require('../lib/build/parser/task').task; |
3 |
| -vartrimCommandValue=require('../lib/build/parser/cleanup').trimCommandValue; |
4 |
| - |
5 |
| -varresult=function(){ |
6 |
| -return{ |
7 |
| -chapters:[{ |
8 |
| -pages:[{ |
9 |
| -tasks:[] |
10 |
| -}] |
11 |
| -}] |
12 |
| -}; |
13 |
| -}; |
14 |
| -varindex=function(){ |
15 |
| -return{ |
16 |
| -chapter:0, |
17 |
| -page:0, |
18 |
| -task:-1 |
19 |
| -}; |
20 |
| -}; |
21 |
| - |
22 |
| -describe('trimCommandValue',function(){ |
23 |
| - |
24 |
| -it('should not effect a normal command',function(){ |
| 1 | +const{ expect}=require('chai'); |
| 2 | +const{ task}=require('../lib/build/parser/task'); |
| 3 | +const{ trimCommandValue}=require('../lib/build/parser/cleanup'); |
| 4 | + |
| 5 | +constresult=()=>({ |
| 6 | +pages:[{ |
| 7 | +tasks:[] |
| 8 | +}] |
| 9 | +}); |
| 10 | + |
| 11 | +constindex=()=>({ |
| 12 | +page:0, |
| 13 | +task:-1 |
| 14 | +}); |
| 15 | + |
| 16 | +describe('trimCommandValue',()=>{ |
| 17 | + |
| 18 | +it('should not effect a normal command',()=>{ |
25 | 19 | expect(trimCommandValue("do('something')")).to.equal("do('something')");
|
26 | 20 | });
|
27 | 21 |
|
28 |
| -it('should trim leading spaces',function(){ |
| 22 | +it('should trim leading spaces',()=>{ |
29 | 23 | expect(trimCommandValue("do( 'something')")).to.equal("do('something')");
|
30 | 24 | });
|
31 | 25 |
|
32 | 26 | });
|
33 | 27 |
|
34 |
| -describe('task',function(){ |
| 28 | +describe('task',()=>{ |
35 | 29 |
|
36 |
| -it('should return a trimmed task description',function(){ |
37 |
| -varlines=['+ Task One']; |
38 |
| -varnext=task(result(),lines,index()); |
39 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
| 30 | +it('should return a trimmed task description',()=>{ |
| 31 | +constlines=['+ Task One']; |
| 32 | +constnext=task({result:result(), lines,index:index()}); |
| 33 | +constnextTask=next.pages[0].tasks[0]; |
40 | 34 | expect(nextTask.description).to.equal('Task One');
|
41 | 35 | });
|
42 | 36 |
|
43 |
| -it('should return a multi-line task description',function(){ |
44 |
| -varlines=['+ Task One','with more on the next','line']; |
45 |
| -varnext=task(result(),lines,index()); |
46 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
| 37 | +it('should return a multi-line task description',()=>{ |
| 38 | +constlines=['+ Task One','with more on the next','line']; |
| 39 | +constnext=task({result:result(), lines,index:index()}); |
| 40 | +constnextTask=next.pages[0].tasks[0]; |
47 | 41 | expect(nextTask.description).to.equal('Task One\nwith more on the next\nline');
|
48 | 42 | });
|
49 | 43 |
|
50 |
| -it('exits on next chapter',function(){ |
51 |
| -varlines=['+ Task One','with more on the next','## Chapter Two']; |
52 |
| -varnext=task(result(),lines,index()); |
53 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
| 44 | +it('exits on next chapter',()=>{ |
| 45 | +constlines=['+ Task One','with more on the next','## Chapter Two']; |
| 46 | +constnext=task({result:result(), lines,index:index()}); |
| 47 | +constnextTask=next.pages[0].tasks[0]; |
54 | 48 | expect(nextTask.description).to.equal('Task One\nwith more on the next');
|
55 | 49 | });
|
56 | 50 |
|
57 |
| -it('exits on next page',function(){ |
58 |
| -varlines=['+ Task One','with more on the next','### Page Two']; |
59 |
| -varnext=task(result(),lines,index()); |
60 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
| 51 | +it('exits on next page',()=>{ |
| 52 | +constlines=['+ Task One','with more on the next','## Page Two']; |
| 53 | +constnext=task({result:result(), lines,index:index()}); |
| 54 | +constnextTask=next.pages[0].tasks[0]; |
61 | 55 | expect(nextTask.description).to.equal('Task One\nwith more on the next');
|
62 | 56 | });
|
63 | 57 |
|
64 |
| -it('exits on next task',function(){ |
65 |
| -varlines=['+ Task One','with more on the next','+ Task Two']; |
66 |
| -varnext=task(result(),lines,index()); |
67 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
| 58 | +it('exits on next task',()=>{ |
| 59 | +constlines=['+ Task One','with more on the next','+ Task Two']; |
| 60 | +constnext=task({result:result(), lines,index:index()}); |
| 61 | +constnextTask=next.pages[0].tasks[0]; |
68 | 62 | expect(nextTask.description).to.equal('Task One\nwith more on the next');
|
69 | 63 | });
|
70 | 64 |
|
71 |
| -it('should import lines in task',function(){ |
72 |
| -varlines=['+ Task description','',"@import('./test/imports/chapter-sample')"] |
73 |
| -varnext=task(result(),lines,index()); |
74 |
| -varnextChapter=next.chapters[1]; |
75 |
| -expect(nextChapter.title).to.equal('Chapter Sample'); |
76 |
| -}); |
77 |
| - |
78 |
| -it('should acceptmultpile import lines in task',function(){ |
79 |
| -varlines=['+ Task description','', |
80 |
| -"@import('./test/imports/chapter-sample')","@import('./test/imports/chapter-sample')" |
81 |
| -] |
82 |
| -varnext=task(result(),lines,index()); |
83 |
| -varnextChapter=next.chapters[2]; |
84 |
| -expect(nextChapter.title).to.equal('Chapter Sample'); |
85 |
| -}); |
86 |
| - |
87 |
| -it('should add codeblock languages',function(){ |
88 |
| -varlines=['+ Task One','```js','var a = 42;','```']; |
89 |
| -varnext=task(result(),lines,index()); |
90 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
91 |
| -expect(nextTask.description).to.equal('Task One\n```js\nvar a = 42;\n```'); |
| 65 | +//it('should import lines in task',() => { |
| 66 | +// const lines = ['+ Task description', '', "@import('./test/imports/chapter-sample')"] |
| 67 | +// constnext = task({result: result(), lines, index: index() }); |
| 68 | +// const nextChapter = next.chapters[1]; |
| 69 | +// expect(nextChapter.title).to.equal('Chapter Sample'); |
| 70 | +//}); |
| 71 | +// |
| 72 | +//it('should acceptmultiple import lines in task',() => { |
| 73 | +// const lines = ['+ Task description', '', |
| 74 | +// "@import('./test/imports/chapter-sample')", "@import('./test/imports/chapter-sample')" |
| 75 | +// ] |
| 76 | +// constnext = task({result: result(), lines, index: index() }); |
| 77 | +// const nextChapter = next.chapters[2]; |
| 78 | +// expect(nextChapter.title).to.equal('Chapter Sample'); |
| 79 | +//}); |
| 80 | + |
| 81 | +it('should add codeblock languages',()=>{ |
| 82 | +constlines=['+ Task One','```js','const a = 42;','```']; |
| 83 | +constnext=task({result:result(), lines,index:index()}); |
| 84 | +constnextTask=next.pages[0].tasks[0]; |
| 85 | +expect(nextTask.description).to.equal('Task One\n```js\nconst a = 42;\n```'); |
92 | 86 | });
|
93 | 87 |
|
94 |
| -it('should add single line codeblocks',function(){ |
95 |
| -varlines=['+ Task One','```var a = 42;```']; |
96 |
| -varnext=task(result(),lines,index()); |
97 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
98 |
| -expect(nextTask.description).to.equal('Task One\n```var a = 42;```'); |
| 88 | +it('should add single line codeblocks',()=>{ |
| 89 | +constlines=['+ Task One','```const a = 42;```']; |
| 90 | +constnext=task({result:result(), lines,index:index()}); |
| 91 | +constnextTask=next.pages[0].tasks[0]; |
| 92 | +expect(nextTask.description).to.equal('Task One\n```const a = 42;```'); |
99 | 93 | });
|
100 | 94 |
|
101 |
| -it('should handle strangely formatted codeblocks',function(){ |
102 |
| -varlines=['+ Task One','```var a = 42;','```']; |
103 |
| -varnext=task(result(),lines,index()); |
104 |
| -varnextTask=next.chapters[0].pages[0].tasks[0]; |
105 |
| -expect(nextTask.description).to.equal('Task One\n```var a = 42;\n```'); |
| 95 | +it('should handle strangely formatted codeblocks',()=>{ |
| 96 | +constlines=['+ Task One','```const a = 42;','```']; |
| 97 | +constnext=task({result:result(), lines,index:index()}); |
| 98 | +constnextTask=next.pages[0].tasks[0]; |
| 99 | +expect(nextTask.description).to.equal('Task One\n```const a = 42;\n```'); |
106 | 100 | });
|
107 | 101 |
|
108 | 102 | });// task
|