diff --git a/src/diagrams/gantt/ganttDb.spec.ts b/src/diagrams/gantt/ganttDb.spec.ts index 035e74e86..d186d47b6 100644 --- a/src/diagrams/gantt/ganttDb.spec.ts +++ b/src/diagrams/gantt/ganttDb.spec.ts @@ -27,7 +27,7 @@ describe('when using the ganttDb', function () { ${'1f'} | ${moment.duration.invalid()} ` )('should $str resulting in $expected duration', ({ str, expected }) => { - expect(ganttDb.parseDuration(str).toString()).not.toEqual(expected); + expect(ganttDb.parseDuration(str)).toEqual(expected); }); }); diff --git a/src/tests/util.ts b/src/tests/util.ts index 9ec74e629..76f8572e3 100644 --- a/src/tests/util.ts +++ b/src/tests/util.ts @@ -1,6 +1,31 @@ /* - * Used to convert Tagged Template literals to object arrays as required by vitest. - */ +Used to convert jest's Tagged Template literals to object arrays as required by vitest. + +Example: + +Jest code +```ts +it.each` +str | expected +${'1d'} | ${moment.duration(1, 'd')} +${'2w'} | ${moment.duration(2, 'w')} +`('should parse $str to $expected duration', ({ str, expected }) => { + expect(yourFunction(str)).toEqual(expected); + }); +``` + +Vitest code +```ts +it.each(convert` +str | expected +${'1d'} | ${moment.duration(1, 'd')} +${'2w'} | ${moment.duration(2, 'w')} +`)('should parse $str to $expected duration', ({ str, expected }) => { + expect(yourFunction(str)).toEqual(expected); + }); +``` +*/ + export const convert = (template: TemplateStringsArray, ...params: any[]) => { const header = template[0] .trim()