Skip to content

Commit 7a82c32

Browse files
committed
fix: use a loop instead of a switch statement
1 parent 54a07f3 commit 7a82c32

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

test/unit/app/utils/charts.spec.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,26 +1527,23 @@ describe('createSeededSvgPattern', () => {
15271527
'backbone',
15281528
]
15291529

1530+
const expectedTagByPatternType: Record<
1531+
ReturnType<typeof createSeededSvgPattern>['patternType'],
1532+
string
1533+
> = {
1534+
diagonalLines: '<line',
1535+
verticalLines: '<line',
1536+
horizontalLines: '<line',
1537+
crosshatch: '<line',
1538+
dots: '<circle',
1539+
grid: '<line',
1540+
zigzag: '<path',
1541+
}
1542+
15301543
for (const seed of seeds) {
15311544
const result = createSeededSvgPattern(seed)
1532-
1533-
switch (result.patternType) {
1534-
case 'dots':
1535-
expect(result.contentMarkup).toContain('<circle')
1536-
break
1537-
1538-
case 'zigzag':
1539-
expect(result.contentMarkup).toContain('<path')
1540-
break
1541-
1542-
case 'diagonalLines':
1543-
case 'verticalLines':
1544-
case 'horizontalLines':
1545-
case 'crosshatch':
1546-
case 'grid':
1547-
expect(result.contentMarkup).toContain('<line')
1548-
break
1549-
}
1545+
const expectedTag = expectedTagByPatternType[result.patternType]
1546+
expect(result.contentMarkup).toContain(expectedTag)
15501547
}
15511548
})
15521549

0 commit comments

Comments
 (0)