Skip to content

Commit e0326f9

Browse files
committed
fix: add coderabbit suggested test cases
1 parent 46cf169 commit e0326f9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,18 @@ describe('computeLineChartAnalysis', () => {
790790
})
791791

792792
describe('createAltTextForTrendLineChart', () => {
793+
it('handles dataset with empty lines without throwing', () => {
794+
const { translate } = createTranslateMock()
795+
const trendLineConfig = createTrendLineConfig({ $t: translate })
796+
797+
expect(() =>
798+
createAltTextForTrendLineChart({
799+
dataset: { lines: [] },
800+
config: trendLineConfig,
801+
} as AltCopyArgs<TrendLineDataset, TrendLineConfig>),
802+
).not.toThrow()
803+
})
804+
793805
it('returns empty string when dataset is null', () => {
794806
const translateMock = createTranslateMock()
795807
const trendLineConfig = createTrendLineConfig({ $t: translateMock.translate })
@@ -1052,6 +1064,18 @@ describe('copyAltTextForTrendLineChart', () => {
10521064
})
10531065

10541066
describe('createAltTextForVersionsBarChart', () => {
1067+
it('handles dataset with empty bars without throwing', () => {
1068+
const { translate } = createTranslateMock()
1069+
const config = createVersionsBarConfigForTests({ $t: translate as any })
1070+
1071+
expect(() =>
1072+
createAltTextForVersionsBarChart({
1073+
dataset: { bars: [] },
1074+
config,
1075+
} as AltCopyArgs<VersionsBarDataset, VersionsBarConfig>),
1076+
).not.toThrow()
1077+
})
1078+
10551079
it('returns empty string when dataset is null (does not translate)', () => {
10561080
const { translate, calls } = createTranslateMock()
10571081
const config = createVersionsBarConfigForTests({ $t: translate as any })

0 commit comments

Comments
 (0)