mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 09:20:03 +02:00
test(gantt.spec): add assertions to check that the parser didn't error
This commit is contained in:
@@ -3,6 +3,12 @@
|
|||||||
import { parser } from './gantt'
|
import { parser } from './gantt'
|
||||||
import ganttDb from '../ganttDb'
|
import ganttDb from '../ganttDb'
|
||||||
|
|
||||||
|
const parserFnConstructor = (str) => {
|
||||||
|
return () => {
|
||||||
|
parser.parse(str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe('when parsing a gantt diagram it', function () {
|
describe('when parsing a gantt diagram it', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
parser.yy = ganttDb
|
parser.yy = ganttDb
|
||||||
@@ -12,23 +18,23 @@ describe('when parsing a gantt diagram it', function () {
|
|||||||
it('should handle a dateFormat definition', function () {
|
it('should handle a dateFormat definition', function () {
|
||||||
const str = 'gantt\ndateFormat yyyy-mm-dd'
|
const str = 'gantt\ndateFormat yyyy-mm-dd'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle a inclusive end date definition', function () {
|
it('should handle a inclusive end date definition', function () {
|
||||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ninclusiveEndDates'
|
const str = 'gantt\ndateFormat yyyy-mm-dd\ninclusiveEndDates'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
})
|
})
|
||||||
it('should handle a title definition', function () {
|
it('should handle a title definition', function () {
|
||||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'
|
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
})
|
})
|
||||||
it('should handle an excludes definition', function () {
|
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'
|
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid\nexcludes weekdays 2019-02-01'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
})
|
})
|
||||||
it('should handle a section definition', function () {
|
it('should handle a section definition', function () {
|
||||||
const str = 'gantt\n' +
|
const str = 'gantt\n' +
|
||||||
@@ -37,7 +43,7 @@ describe('when parsing a gantt diagram it', function () {
|
|||||||
'excludes weekdays 2019-02-01\n' +
|
'excludes weekdays 2019-02-01\n' +
|
||||||
'section Documentation'
|
'section Documentation'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Beslutsflöde inligt nedan. Obs bla bla bla
|
* Beslutsflöde inligt nedan. Obs bla bla bla
|
||||||
@@ -57,7 +63,7 @@ describe('when parsing a gantt diagram it', function () {
|
|||||||
'section Documentation\n' +
|
'section Documentation\n' +
|
||||||
'Design jison grammar:des1, 2014-01-01, 2014-01-04'
|
'Design jison grammar:des1, 2014-01-01, 2014-01-04'
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
|
|
||||||
const tasks = parser.yy.getTasks()
|
const tasks = parser.yy.getTasks()
|
||||||
|
|
||||||
@@ -82,7 +88,7 @@ describe('when parsing a gantt diagram it', function () {
|
|||||||
|
|
||||||
const allowedTags = ['active', 'done', 'crit', 'milestone']
|
const allowedTags = ['active', 'done', 'crit', 'milestone']
|
||||||
|
|
||||||
parser.parse(str)
|
expect(parserFnConstructor(str)).not.toThrow()
|
||||||
|
|
||||||
const tasks = parser.yy.getTasks()
|
const tasks = parser.yy.getTasks()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user