2017-04-11 16:57:57 +02:00
|
|
|
/* eslint-env jasmine */
|
2017-09-10 15:23:04 +02:00
|
|
|
import { parser } from './parser/gantt'
|
|
|
|
import ganttDb from './ganttDb'
|
2019-02-01 09:16:28 +01:00
|
|
|
import moment from 'moment'
|
2017-09-10 15:23:04 +02:00
|
|
|
|
2017-04-11 16:14:25 +02:00
|
|
|
describe('when parsing a gantt diagram it', function () {
|
|
|
|
beforeEach(function () {
|
2017-09-10 15:23:04 +02:00
|
|
|
parser.yy = ganttDb
|
2019-02-01 09:16:28 +01:00
|
|
|
parser.yy.clear()
|
2017-04-11 16:14:25 +02:00
|
|
|
})
|
|
|
|
|
2017-11-18 16:18:24 +01:00
|
|
|
it('should handle a dateFormat definition', function () {
|
2017-09-14 14:27:52 +02:00
|
|
|
const str = 'gantt\ndateFormat yyyy-mm-dd'
|
2017-04-11 16:14:25 +02:00
|
|
|
|
2017-09-10 15:23:04 +02:00
|
|
|
parser.parse(str)
|
2017-04-11 16:14:25 +02:00
|
|
|
})
|
2017-11-18 16:22:49 +01:00
|
|
|
it('should handle a title definition', function () {
|
2017-09-14 14:27:52 +02:00
|
|
|
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'
|
2017-04-11 16:14:25 +02:00
|
|
|
|
2017-09-10 15:23:04 +02:00
|
|
|
parser.parse(str)
|
2017-04-11 16:14:25 +02:00
|
|
|
})
|
2017-11-18 16:18:24 +01:00
|
|
|
it('should handle a section definition', function () {
|
2017-11-18 16:22:49 +01:00
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat yyyy-mm-dd\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation'
|
2017-04-11 16:14:25 +02:00
|
|
|
|
2017-09-10 15:23:04 +02:00
|
|
|
parser.parse(str)
|
2017-04-11 16:14:25 +02:00
|
|
|
})
|
2017-04-16 17:48:36 +02:00
|
|
|
/**
|
|
|
|
* Beslutsflöde inligt nedan. Obs bla bla bla
|
|
|
|
* ```
|
|
|
|
* graph TD
|
|
|
|
* A[Hard pledge] -- text on link -->B(Round edge)
|
|
|
|
* B --> C{to do or not to do}
|
|
|
|
* C -->|Too| D[Result one]
|
|
|
|
* C -->|Doo| E[Result two]
|
|
|
|
```
|
|
|
|
* params bapa - a unique bapap
|
|
|
|
*/
|
2017-04-11 16:14:25 +02:00
|
|
|
it('should handle a task definition', function () {
|
2017-09-14 14:27:52 +02:00
|
|
|
const str = 'gantt\n' +
|
2019-02-01 09:16:28 +01:00
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
2017-04-16 17:48:36 +02:00
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'Design jison grammar:des1, 2014-01-01, 2014-01-04'
|
2015-02-08 20:07:15 +01:00
|
|
|
|
2017-09-10 15:23:04 +02:00
|
|
|
parser.parse(str)
|
2019-02-01 09:16:28 +01:00
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
|
|
|
|
expect(tasks[0].startTime).toEqual(moment('2014-01-01', 'YYYY-MM-DD').toDate())
|
|
|
|
expect(tasks[0].endTime).toEqual(moment('2014-01-04', 'YYYY-MM-DD').toDate())
|
|
|
|
expect(tasks[0].id).toEqual('des1')
|
|
|
|
expect(tasks[0].task).toEqual('Design jison grammar')
|
|
|
|
})
|
|
|
|
it('should handle a milestone task', function () {
|
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'test task:milestone, 2014-01-01, 2014-01-04'
|
|
|
|
|
|
|
|
parser.parse(str)
|
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
expect(tasks[0].milestone).toBeTruthy()
|
|
|
|
expect(tasks[0].done).toBeFalsy()
|
|
|
|
expect(tasks[0].crit).toBeFalsy()
|
|
|
|
expect(tasks[0].active).toBeFalsy()
|
|
|
|
})
|
|
|
|
it('should handle a done task', function () {
|
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'test task:done, 2014-01-01, 2014-01-04'
|
|
|
|
|
|
|
|
parser.parse(str)
|
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
expect(tasks[0].milestone).toBeFalsy()
|
|
|
|
expect(tasks[0].done).toBeTruthy()
|
|
|
|
expect(tasks[0].crit).toBeFalsy()
|
|
|
|
expect(tasks[0].active).toBeFalsy()
|
|
|
|
})
|
|
|
|
it('should handle a critical task', function () {
|
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'test task:crit, 2014-01-01, 2014-01-04'
|
|
|
|
|
|
|
|
parser.parse(str)
|
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
expect(tasks[0].milestone).toBeFalsy()
|
|
|
|
expect(tasks[0].done).toBeFalsy()
|
|
|
|
expect(tasks[0].crit).toBeTruthy()
|
|
|
|
expect(tasks[0].active).toBeFalsy()
|
|
|
|
})
|
|
|
|
it('should handle an active task', function () {
|
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'test task:active, 2014-01-01, 2014-01-04'
|
|
|
|
|
|
|
|
parser.parse(str)
|
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
expect(tasks[0].milestone).toBeFalsy()
|
|
|
|
expect(tasks[0].done).toBeFalsy()
|
|
|
|
expect(tasks[0].crit).toBeFalsy()
|
|
|
|
expect(tasks[0].active).toBeTruthy()
|
|
|
|
})
|
|
|
|
it('should handle task with multiple tags', function () {
|
|
|
|
const str = 'gantt\n' +
|
|
|
|
'dateFormat YYYY-MM-DD\n' +
|
|
|
|
'title Adding gantt diagram functionality to mermaid\n' +
|
|
|
|
'section Documentation\n' +
|
|
|
|
'test task:crit,milestone,done, 2014-01-01, 2014-01-04'
|
|
|
|
|
|
|
|
parser.parse(str)
|
|
|
|
|
|
|
|
const tasks = parser.yy.getTasks()
|
|
|
|
expect(tasks[0].milestone).toBeTruthy()
|
|
|
|
expect(tasks[0].done).toBeTruthy()
|
|
|
|
expect(tasks[0].crit).toBeTruthy()
|
|
|
|
expect(tasks[0].active).toBeFalsy()
|
2017-04-11 16:14:25 +02:00
|
|
|
})
|
|
|
|
})
|