Skip to content

Commit

Permalink
Add tests for invalid date ranges and invalid range syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
paldeep-singh committed Mar 10, 2024
1 parent 7480eec commit 0444adb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ describe('when parsing a gantt diagram it', function () {

expect(parserFnConstructor(str)).not.toThrow();
});
it.each([
['dateRange: 2023-06-01, 2023-07-01', 'YYYY-MM-DD'],
['dateRange: 13:00, 14:00', 'HH:mm'],
])('should ignore improper dateRange syntax (%s)', function (dateRange, dateFormat) {
const str = `gantt\ndateFormat ${dateFormat}\n${dateRange}`;

expect(parserFnConstructor(str)).not.toThrow();
expect(ganttDb.getDateRange()).toEqual('');
});
it.each([
['dateRange : 2023-06-01, 2023-07-01', 'YYYY-MM-DD'],
['dateRange : 13:00, 14:00', 'HH:mm'],
])(`should reject invalid dateRange definition (%s)`, function (dateRange, dateFormat) {
const str = `gantt\ndateFormat ${dateFormat}\n${dateRange}`;

expect(parserFnConstructor(str)).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';
Expand Down

0 comments on commit 0444adb

Please sign in to comment.