mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Merge pull request #1162 from sdankel/bug/1060_date_infinite_loop
Fix infinite loop caused by date iteration
This commit is contained in:
commit
413876644c
@ -54,4 +54,44 @@ describe('Sequencediagram', () => {
|
||||
{}
|
||||
);
|
||||
});
|
||||
it('should render a gantt chart for issue #1060', () => {
|
||||
imgSnapshotTest(
|
||||
`
|
||||
gantt
|
||||
excludes weekdays 2017-01-10
|
||||
title Projects Timeline
|
||||
|
||||
section asdf
|
||||
specs :done, :ps, 2019-05-10, 50d
|
||||
Plasma :pc, 2019-06-20, 60d
|
||||
Rollup :or, 2019-08-20, 50d
|
||||
|
||||
section CEL
|
||||
|
||||
plasma-chamber :done, :pc, 2019-05-20, 60d
|
||||
Plasma Implementation (Rust) :por, 2019-06-20, 120d
|
||||
Predicates (Atomic Swap) :pred, 2019-07-20, 60d
|
||||
|
||||
section DEX 💰
|
||||
|
||||
History zkSNARK :hs, 2019-08-10, 40d
|
||||
Exit :vs, after hs, 60d
|
||||
PredicateSpec :ps, 2019-09-1, 20d
|
||||
PlasmaIntegration :pi, after ps,40d
|
||||
|
||||
|
||||
section Events 🏁
|
||||
|
||||
ETHBoston :done, :eb, 2019-09-08, 3d
|
||||
DevCon :active, :dc, 2019-10-08, 3d
|
||||
|
||||
section Plasma Calls & updates ✨
|
||||
OVM :ovm, 2019-07-12, 120d
|
||||
Plasma call 26 :pc26, 2019-08-21, 1d
|
||||
Plasma call 27 :pc27, 2019-09-03, 1d
|
||||
Plasma call 28 :pc28, 2019-09-17, 1d
|
||||
`,
|
||||
{}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -117,7 +117,7 @@ const checkTaskDates = function(task, dateFormat, excludes) {
|
||||
const fixTaskDates = function(startTime, endTime, dateFormat, excludes) {
|
||||
let invalid = false;
|
||||
let renderEndTime = null;
|
||||
while (startTime.date() <= endTime.date()) {
|
||||
while (startTime <= endTime) {
|
||||
if (!invalid) {
|
||||
renderEndTime = endTime.toDate();
|
||||
}
|
||||
|
@ -174,6 +174,26 @@ describe('when using the ganttDb', function() {
|
||||
expect(tasks[6].task).toEqual('test7');
|
||||
});
|
||||
|
||||
it('should work when end date is the 31st', function() {
|
||||
ganttDb.setDateFormat('YYYY-MM-DD');
|
||||
ganttDb.addSection('Task endTime is on the 31st day of the month');
|
||||
ganttDb.addTask('test1', 'id1,2019-09-30,11d');
|
||||
ganttDb.addTask('test2', 'id2,after id1,20d');
|
||||
const tasks = ganttDb.getTasks();
|
||||
|
||||
expect(tasks[0].startTime).toEqual(moment('2019-09-30', 'YYYY-MM-DD').toDate());
|
||||
expect(tasks[0].endTime).toEqual(moment('2019-10-11', 'YYYY-MM-DD').toDate());
|
||||
expect(tasks[1].renderEndTime).toBeNull(); // Fixed end
|
||||
expect(tasks[0].id).toEqual('id1');
|
||||
expect(tasks[0].task).toEqual('test1');
|
||||
|
||||
expect(tasks[1].startTime).toEqual(moment('2019-10-11', 'YYYY-MM-DD').toDate());
|
||||
expect(tasks[1].endTime).toEqual(moment('2019-10-31', 'YYYY-MM-DD').toDate());
|
||||
expect(tasks[1].renderEndTime).toBeNull(); // Fixed end
|
||||
expect(tasks[1].id).toEqual('id2');
|
||||
expect(tasks[1].task).toEqual('test2');
|
||||
});
|
||||
|
||||
describe('when setting inclusive end dates', function() {
|
||||
beforeEach(function() {
|
||||
ganttDb.setDateFormat('YYYY-MM-DD');
|
||||
|
Loading…
x
Reference in New Issue
Block a user