Merge pull request #3355 from vallsv/feature-ms-duration
This commit is contained in:
commit
cde3a7cf70
|
@ -163,6 +163,24 @@ describe('Gantt diagram', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle milliseconds', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
gantt
|
||||||
|
title A Gantt Diagram
|
||||||
|
dateFormat x
|
||||||
|
axisFormat %L
|
||||||
|
section Section
|
||||||
|
A task :a1, 0, 30ms
|
||||||
|
Another task :after a1, 20ms
|
||||||
|
section Another
|
||||||
|
Another another task :b1, 20, 12ms
|
||||||
|
Another another another task :after b1, 24ms
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should render a gantt diagram when useMaxWidth is true (default)', () => {
|
it('should render a gantt diagram when useMaxWidth is true (default)', () => {
|
||||||
renderGraph(
|
renderGraph(
|
||||||
`
|
`
|
||||||
|
|
|
@ -233,6 +233,9 @@ const getStartDate = function (prevTime, dateFormat, str) {
|
||||||
const durationToDate = function (durationStatement, relativeTime) {
|
const durationToDate = function (durationStatement, relativeTime) {
|
||||||
if (durationStatement !== null) {
|
if (durationStatement !== null) {
|
||||||
switch (durationStatement[2]) {
|
switch (durationStatement[2]) {
|
||||||
|
case 'ms':
|
||||||
|
relativeTime.add(durationStatement[1], 'milliseconds');
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
relativeTime.add(durationStatement[1], 'seconds');
|
relativeTime.add(durationStatement[1], 'seconds');
|
||||||
break;
|
break;
|
||||||
|
@ -267,7 +270,7 @@ const getEndDate = function (prevTime, dateFormat, str, inclusive) {
|
||||||
return mDate.toDate();
|
return mDate.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return durationToDate(/^([\d]+)([wdhms])/.exec(str.trim()), moment(prevTime));
|
return durationToDate(/^([\d]+)([wdhms]|ms)$/.exec(str.trim()), moment(prevTime));
|
||||||
};
|
};
|
||||||
|
|
||||||
let taskCnt = 0;
|
let taskCnt = 0;
|
||||||
|
|
|
@ -99,6 +99,27 @@ describe('when using the ganttDb', function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('should handle milliseconds', function () {
|
||||||
|
ganttDb.setDateFormat('x');
|
||||||
|
ganttDb.addSection('testa1');
|
||||||
|
ganttDb.addTask('test1', 'id1,0,20ms');
|
||||||
|
ganttDb.addTask('test2', 'id2,after id1,5ms');
|
||||||
|
ganttDb.addSection('testa2');
|
||||||
|
ganttDb.addTask('test3', 'id3,20,10ms');
|
||||||
|
ganttDb.addTask('test4', 'id4,after id3,5ms');
|
||||||
|
|
||||||
|
const tasks = ganttDb.getTasks();
|
||||||
|
|
||||||
|
expect(tasks[0].startTime.toISOString()).toEqual('1970-01-01T00:00:00.000Z');
|
||||||
|
expect(tasks[0].endTime.toISOString()).toEqual('1970-01-01T00:00:00.020Z');
|
||||||
|
expect(tasks[1].startTime.toISOString()).toEqual('1970-01-01T00:00:00.020Z');
|
||||||
|
expect(tasks[1].endTime.toISOString()).toEqual('1970-01-01T00:00:00.025Z');
|
||||||
|
expect(tasks[2].startTime.toISOString()).toEqual('1970-01-01T00:00:00.020Z');
|
||||||
|
expect(tasks[2].endTime.toISOString()).toEqual('1970-01-01T00:00:00.030Z');
|
||||||
|
expect(tasks[3].startTime.toISOString()).toEqual('1970-01-01T00:00:00.030Z');
|
||||||
|
expect(tasks[3].endTime.toISOString()).toEqual('1970-01-01T00:00:00.035Z');
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle relative start date based on id regardless of sections', function () {
|
it('should handle relative start date based on id regardless of sections', function () {
|
||||||
ganttDb.setDateFormat('YYYY-MM-DD');
|
ganttDb.setDateFormat('YYYY-MM-DD');
|
||||||
ganttDb.addSection('testa1');
|
ganttDb.addSection('testa1');
|
||||||
|
|
Loading…
Reference in New Issue