Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecee321

Browse files
committed
update build-task tests, fix task call to loadImports
1 parentaa24085 commitecee321

File tree

5 files changed

+78
-84
lines changed

5 files changed

+78
-84
lines changed

‎lib/build/parser/page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function page(_a) {
88
index.page+=1;
99
index.task=-1;
1010
result.pages.push({
11-
title:Match.page(lines[0]).trim(),
11+
title:Match.page(lines[0]),
1212
description:''
1313
});
1414
varinCodeBlock=false;
@@ -20,7 +20,7 @@ function page(_a) {
2020
varline=lines[i];
2121
switch(true){
2222
case!!Match.isImport(line):
23-
lines=import_1.loadImport(dir,lines,Match.isImport(line));
23+
lines=import_1.loadImport({dir:dir,lines:lines,pathToMd:Match.isImport(line)});
2424
continue;
2525
case(!!Match.isPageComplete(line)||!!currentPageComplete):
2626
currentPageComplete=!!currentPageComplete

‎lib/build/parser/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function task(_a) {
2020
varline=lines[i];
2121
switch(true){
2222
case!!Match.isImport(line):
23-
lines=import_1.loadImport(dir,lines,Match.isImport(line));
23+
lines=import_1.loadImport({dir:dir,lines:lines,pathToMd:Match.isImport(line)});
2424
continue;
2525
case(!!Match.isPageComplete(line)||!!currentPageComplete):
2626
currentPageComplete=!!currentPageComplete

‎src/build/parser/page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {task} from './task';
33
import{loadImport}from'./import';
44
import{bracketTracker,trimValue}from'./cleanup';
55

6-
exportfunctionpage({ dir, result, lines, index}){
6+
exportfunctionpage({ dir, result, lines, index}){
77
index.page+=1;
88
index.task=-1;
99
result.pages.push({
10-
title:Match.page(lines[0]).trim(),
10+
title:Match.page(lines[0]),
1111
description:''
1212
});
1313
letinCodeBlock=false;
@@ -23,7 +23,7 @@ export function page({ dir, result, lines, index}) {
2323

2424
//@import
2525
case!!Match.isImport(line):
26-
lines=loadImport(dir,lines,Match.isImport(line));
26+
lines=loadImport({dir, lines,pathToMd:Match.isImport(line)});
2727
continue;
2828

2929
//@onComplete

‎src/build/parser/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function task({
2525

2626
//@import
2727
case!!Match.isImport(line):
28-
lines=loadImport(dir,lines,Match.isImport(line));
28+
lines=loadImport({dir, lines,pathToMd:Match.isImport(line)});
2929
continue;
3030

3131
//@onComplete

‎test/build-task.spec.js

Lines changed: 71 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,102 @@
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',()=>{
2519
expect(trimCommandValue("do('something')")).to.equal("do('something')");
2620
});
2721

28-
it('should trim leading spaces',function(){
22+
it('should trim leading spaces',()=>{
2923
expect(trimCommandValue("do( 'something')")).to.equal("do('something')");
3024
});
3125

3226
});
3327

34-
describe('task',function(){
28+
describe('task',()=>{
3529

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];
4034
expect(nextTask.description).to.equal('Task One');
4135
});
4236

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];
4741
expect(nextTask.description).to.equal('Task One\nwith more on the next\nline');
4842
});
4943

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];
5448
expect(nextTask.description).to.equal('Task One\nwith more on the next');
5549
});
5650

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];
6155
expect(nextTask.description).to.equal('Task One\nwith more on the next');
6256
});
6357

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];
6862
expect(nextTask.description).to.equal('Task One\nwith more on the next');
6963
});
7064

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```');
9286
});
9387

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;```');
9993
});
10094

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```');
106100
});
107101

108102
});// task

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp