mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Changes to gantt.html
1. Added a Gantt diagram that demonstrates to users that hashtages and semicolons can be added to titles, sections, and task data. Changes to gantt.spec.js 1. Added unit tests to ensure that semicolons and hashtags didn't break the functionality of the gantt diagram when used in titles, sections or task data. Changes to /parser/gantt.spec.js 1. Added rendering tests to ensure that semicolons and hashtags in titles, sections, and task data didn't break the rendering of Gantt diagrams.
This commit is contained in:
parent
0b0f988180
commit
59264a33d7
@ -583,4 +583,106 @@ describe('Gantt diagram', () => {
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a semicolon in the title", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title ;Gantt With a Semicolon in the Title
|
||||
dateFormat YYYY-MM-DD
|
||||
section Section
|
||||
A task :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a semicolon in a section is true", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title Gantt Digram
|
||||
dateFormat YYYY-MM-DD
|
||||
section ;Section With a Semicolon
|
||||
A task :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a semicolon in the task data", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title Gantt Digram
|
||||
dateFormat YYYY-MM-DD
|
||||
section Section
|
||||
;A task with a semiclon :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a hashtag in the title", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title #Gantt With a Hashtag in the Title
|
||||
dateFormat YYYY-MM-DD
|
||||
section Section
|
||||
A task :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a hashtag in a section is true", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title Gantt Digram
|
||||
dateFormat YYYY-MM-DD
|
||||
section #Section With a Hashtag
|
||||
A task :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it("should render when there's a hashtag in the task data", () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
title Gantt Digram
|
||||
dateFormat YYYY-MM-DD
|
||||
section Section
|
||||
#A task with a hashtag :a1, 2014-01-01, 30d
|
||||
Another task :after a1 , 20d
|
||||
section Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -30,6 +30,21 @@
|
||||
</pre>
|
||||
<hr />
|
||||
|
||||
<pre class="mermaid">
|
||||
gantt
|
||||
title #; Gantt Diagrams Allow Semicolons and Hashtags #;!
|
||||
accTitle: A simple sample gantt diagram
|
||||
accDescr: 2 sections with 2 tasks each, from 2014
|
||||
dateFormat YYYY-MM-DD
|
||||
section #;Section
|
||||
#;A task :a1, 2014-01-01, 30d
|
||||
#;Another task :after a1 , 20d
|
||||
section #;Another
|
||||
Task in sec :2014-01-12 , 12d
|
||||
another task : 24d
|
||||
</pre>
|
||||
<hr />
|
||||
|
||||
<pre class="mermaid">
|
||||
gantt
|
||||
title Airworks roadmap
|
||||
|
@ -28,8 +28,12 @@ describe('when parsing a gantt diagram it', function () {
|
||||
});
|
||||
it('should handle a title definition', function () {
|
||||
const str = 'gantt\ndateFormat yyyy-mm-dd\ntitle Adding gantt diagram functionality to mermaid';
|
||||
const semi = 'gantt\ndateFormat yyyy-mm-dd\ntitle ;Gantt diagram titles support semicolons';
|
||||
const hash = 'gantt\ndateFormat yyyy-mm-dd\ntitle #Gantt diagram titles support hashtags';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
expect(parserFnConstructor(semi)).not.toThrow();
|
||||
expect(parserFnConstructor(hash)).not.toThrow();
|
||||
});
|
||||
it('should handle an excludes definition', function () {
|
||||
const str =
|
||||
@ -53,7 +57,23 @@ describe('when parsing a gantt diagram it', function () {
|
||||
'excludes weekdays 2019-02-01\n' +
|
||||
'section Documentation';
|
||||
|
||||
const semi =
|
||||
'gantt\n' +
|
||||
'dateFormat yyyy-mm-dd\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'excludes weekdays 2019-02-01\n' +
|
||||
'section ;Documentation';
|
||||
|
||||
const hash =
|
||||
'gantt\n' +
|
||||
'dateFormat yyyy-mm-dd\n' +
|
||||
'title Adding gantt diagram functionality to mermaid\n' +
|
||||
'excludes weekdays 2019-02-01\n' +
|
||||
'section #Documentation';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
expect(parserFnConstructor(semi)).not.toThrow();
|
||||
expect(parserFnConstructor(hash)).not.toThrow();
|
||||
});
|
||||
it('should handle multiline section titles with different line breaks', function () {
|
||||
const str =
|
||||
@ -73,7 +93,23 @@ describe('when parsing a gantt diagram it', function () {
|
||||
'section Documentation\n' +
|
||||
'Design jison grammar:des1, 2014-01-01, 2014-01-04';
|
||||
|
||||
const semi =
|
||||
'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';
|
||||
|
||||
const hash =
|
||||
'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';
|
||||
|
||||
expect(parserFnConstructor(str)).not.toThrow();
|
||||
expect(parserFnConstructor(semi)).not.toThrow();
|
||||
expect(parserFnConstructor(hash)).not.toThrow();
|
||||
|
||||
const tasks = parser.yy.getTasks();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user