Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Sep 7, 2022
1 parent 5905787 commit 407927c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/diagrams/gantt/ganttDb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
29 changes: 27 additions & 2 deletions src/tests/util.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 407927c

Please sign in to comment.