mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 05:19:58 +02:00
#931 Updating code to align witn new code standard
This commit is contained in:
@@ -1,50 +1,52 @@
|
||||
/* eslint-env jasmine */
|
||||
/* eslint-disable no-eval */
|
||||
import { parser } from './gantt'
|
||||
import ganttDb from '../ganttDb'
|
||||
import { parser } from './gantt';
|
||||
import ganttDb from '../ganttDb';
|
||||
|
||||
const parserFnConstructor = (str) => {
|
||||
const parserFnConstructor = str => {
|
||||
return () => {
|
||||
parser.parse(str)
|
||||
}
|
||||
}
|
||||
parser.parse(str);
|
||||
};
|
||||
};
|
||||
|
||||
describe('when parsing a gantt diagram it', function () {
|
||||
beforeEach(function () {
|
||||
parser.yy = ganttDb
|
||||
parser.yy.clear()
|
||||
})
|
||||
describe('when parsing a gantt diagram it', function() {
|
||||
beforeEach(function() {
|
||||
parser.yy = ganttDb;
|
||||
parser.yy.clear();
|
||||
});
|
||||
|
||||
it('should handle a dateFormat definition', function () {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd'
|
||||
it('should handle a dateFormat definition', function() {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
})
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should handle a inclusive end date definition', function () {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ninclusiveEndDates'
|
||||
it('should handle a inclusive end date definition', function() {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ninclusiveEndDates';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
})
|
||||
it('should handle a title definition', function () {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
it('should handle a title definition', function() {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
})
|
||||
it('should handle an excludes definition', function () {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid\nexcludes weekdays 2019-02-01'
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
it('should handle an excludes definition', function() {
|
||||
const str =
|
||||
'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid\nexcludes weekdays 2019-02-01';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
})
|
||||
it('should handle a section definition', function () {
|
||||
const str = 'gantt\n' +
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
it('should handle a section definition', function() {
|
||||
const str =
|
||||
'gantt\n' +
|
||||
'dateFormat yyyy-mm-dd\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'excludes weekdays 2019-02-01\n' +
|
||||
'section Documentation'
|
||||
'section Documentation';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
})
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
});
|
||||
/**
|
||||
* Beslutsflöde inligt nedan. Obs bla bla bla
|
||||
* ```
|
||||
@@ -56,22 +58,23 @@ describe('when parsing a gantt diagram it', function () {
|
||||
```
|
||||
* params bapa - a unique bapap
|
||||
*/
|
||||
it('should handle a task definition', function () {
|
||||
const str = 'gantt\n' +
|
||||
it('should handle a task definition', function() {
|
||||
const str =
|
||||
'gantt\n' +
|
||||
'dateFormat YYYY-MM-DD\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'section Documentation\n' +
|
||||
'Design jison grammar:des1, 2014-01-01, 2014-01-04'
|
||||
'Design jison grammar:des1, 2014-01-01, 2014-01-04';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
|
||||
const tasks = parser.yy.getTasks()
|
||||
const tasks = parser.yy.getTasks();
|
||||
|
||||
expect(tasks[0].startTime).toEqual(new Date(2014, 0, 1))
|
||||
expect(tasks[0].endTime).toEqual(new Date(2014, 0, 4))
|
||||
expect(tasks[0].id).toEqual('des1')
|
||||
expect(tasks[0].task).toEqual('Design jison grammar')
|
||||
})
|
||||
expect(tasks[0].startTime).toEqual(new Date(2014, 0, 1));
|
||||
expect(tasks[0].endTime).toEqual(new Date(2014, 0, 4));
|
||||
expect(tasks[0].id).toEqual('des1');
|
||||
expect(tasks[0].task).toEqual('Design jison grammar');
|
||||
});
|
||||
it.each`
|
||||
tags | milestone | done | crit | active
|
||||
${'milestone'} | ${true} | ${false} | ${false} | ${false}
|
||||
@@ -79,25 +82,28 @@ describe('when parsing a gantt diagram it', function () {
|
||||
${'crit'} | ${false} | ${false} | ${true} | ${false}
|
||||
${'active'} | ${false} | ${false} | ${false} | ${true}
|
||||
${'crit,milestone,done'} | ${true} | ${true} | ${true} | ${false}
|
||||
`('should handle a task with tags $tags', ({ tags, milestone, done, crit, active }) => {
|
||||
const str = 'gantt\n' +
|
||||
'dateFormat YYYY-MM-DD\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'section Documentation\n' +
|
||||
'test task:' + tags + ', 2014-01-01, 2014-01-04'
|
||||
`('should handle a task with tags $tags', ({ tags, milestone, done, crit, active }) => {
|
||||
const str =
|
||||
'gantt\n' +
|
||||
'dateFormat YYYY-MM-DD\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'section Documentation\n' +
|
||||
'test task:' +
|
||||
tags +
|
||||
', 2014-01-01, 2014-01-04';
|
||||
|
||||
const allowedTags = ['active', 'done', 'crit', 'milestone']
|
||||
const allowedTags = ['active', 'done', 'crit', 'milestone'];
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow()
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
|
||||
const tasks = parser.yy.getTasks()
|
||||
const tasks = parser.yy.getTasks();
|
||||
|
||||
allowedTags.forEach(function (t) {
|
||||
if (eval(t)) {
|
||||
expect(tasks[0][t]).toBeTruthy()
|
||||
} else {
|
||||
expect(tasks[0][t]).toBeFalsy()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
allowedTags.forEach(function(t) {
|
||||
if (eval(t)) {
|
||||
expect(tasks[0][t]).toBeTruthy();
|
||||
} else {
|
||||
expect(tasks[0][t]).toBeFalsy();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user