Skip to content

Commit

Permalink
Fix for broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Oct 7, 2022
1 parent 047e159 commit 646f76d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions V10-BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A collection of updates that change the behaviour

## Lazy loading and asynchronisity

- Invalid dates are rendered as syntax error instead of returning best guess or the current date
2 changes: 1 addition & 1 deletion cypress/integration/rendering/gantt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Gantt diagram', () => {
{}
);
});
it('should render a gantt chart for issue #1060', () => {
it('should FAIL redering a gantt chart for issue #1060 with invalid date', () => {
imgSnapshotTest(
`
gantt
Expand Down
2 changes: 1 addition & 1 deletion cypress/platform/knsv2.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<body>
<div>Security check</div>
<pre id="diagram" class="mermaid">
classDiagram
classDiagram
direction LR
class Student {
-idCard : IdCard
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
"jsdom": "^20.0.1",
"lint-staged": "^13.0.3",
"markdown-it": "^13.0.1",
"moment": "^2.23.0",
"path-browserify": "^1.0.1",
"pnpm": "^7.13.2",
"prettier": "^2.7.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/mermaid/src/diagrams/class/svgDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ const buildLegacyDisplay = function (text) {

const parameters = text.substring(methodStart + 1, methodEnd);
const classifier = text.substring(methodEnd + 1, 1);
cssStyle = parseClassifier(classifier);
cssStyle = parseClassifier(text.substring(methodEnd + 1, methodEnd + 2));

displayText = visibility + methodName + '(' + parseGenericTypes(parameters.trim()) + ')';

if (methodEnd < memberText.length) {
if (methodEnd < text.length) {
returnType = text.substring(methodEnd + 2).trim();
if (returnType !== '') {
returnType = ' : ' + parseGenericTypes(returnType);
Expand Down
8 changes: 5 additions & 3 deletions packages/mermaid/src/diagrams/gantt/ganttDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ const getStartDate = function (prevTime, dateFormat, str) {
} else {
log.debug('Invalid date:' + str);
log.debug('With date format:' + dateFormat.trim());
const d = new Date(str);
if (typeof d === 'undefined' || isNaN(d.getTime())) {
throw new Error('Invalid date:' + str);
}
return d;
}

// Default date - now
return new Date();
};

/**
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 646f76d

Please sign in to comment.