From 89e061aa51aa16b82177bc557a54fe5828e5d2f5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 21 Jun 2024 16:24:02 +0530 Subject: [PATCH] chore: Fix gantt test --- .../src/diagrams/gantt/parser/gantt.spec.js | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index 3416d8e91..43827fb3e 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -157,30 +157,40 @@ describe('when parsing a gantt diagram it', function () { ${'crit'} | ${false} | ${false} | ${true} | ${false} ${'active'} | ${false} | ${false} | ${false} | ${true} ${'crit,milestone,done'} | ${true} | ${true} | ${true} | ${false} - `)('should handle a task with tags $tags', ({ tags }) => { - const str = - 'gantt\n' + - 'dateFormat YYYY-MM-DD\n' + - 'title Adding gantt diagram functionality to mermaid\n' + - 'section Documentation\n' + - 'test task:' + - tags + - ', 2014-01-01, 2014-01-04'; + `)( + 'should handle a task with tags $tags', + ({ + tags, + // Do not remove, these are used in eval. + milestone, + done, + crit, + active, + }) => { + const str = + 'gantt\n' + + 'dateFormat YYYY-MM-DD\n' + + 'title Adding gantt diagram functionality to mermaid\n' + + 'section Documentation\n' + + 'test task:' + + tags + + ', 2014-01-01, 2014-01-04'; - const allowedTags = ['active', 'done', 'crit', 'milestone']; + const allowedTags = ['active', 'done', 'crit', 'milestone']; - expect(parserFnConstructor(str)).not.toThrow(); + expect(parserFnConstructor(str)).not.toThrow(); - const tasks = parser.yy.getTasks(); + const tasks = parser.yy.getTasks(); - allowedTags.forEach(function (t) { - if (eval(t)) { - expect(tasks[0][t]).toBeTruthy(); - } else { - expect(tasks[0][t]).toBeFalsy(); - } - }); - }); + allowedTags.forEach(function (t) { + if (eval(t)) { + expect(tasks[0][t]).toBeTruthy(); + } else { + expect(tasks[0][t]).toBeFalsy(); + } + }); + } + ); it('should parse callback specifier with no args', function () { spyOn(ganttDb, 'setClickEvent'); const str =