Skip to content

Commit f3d52a3

Browse files
fix type error in test
Signed-off-by: Adhitya Mamallan <[email protected]>
1 parent 9b5b0eb commit f3d52a3

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

src/views/workflow-history-v2/workflow-history-details-row/__tests__/workflow-history-details-row.test.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,36 @@ import type { WorkflowPageParams } from '@/views/workflow-page/workflow-page.typ
44

55
import { type EventDetailsEntries } from '../../workflow-history-event-details/workflow-history-event-details.types';
66
import WorkflowHistoryDetailsRow from '../workflow-history-details-row';
7+
import { type DetailsRowItem } from '../workflow-history-details-row.types';
78

89
jest.mock('../helpers/get-parsed-details-row-items', () =>
910
jest.fn((detailsEntries: EventDetailsEntries) =>
10-
detailsEntries
11-
.filter((entry) => !entry.isGroup)
12-
.map((entry, index) => ({
13-
path: entry.path,
14-
label: entry.path,
15-
value: entry.value,
16-
icon: ({ size }: any) => (
17-
<span data-testid={`icon-${entry.path}`} data-size={size} />
18-
),
19-
renderValue: ({ value, isNegative }: any) => (
20-
<span data-testid={`field-${entry.path}`} data-negative={isNegative}>
21-
{value}
22-
</span>
23-
),
24-
renderTooltip: ({ label }: any) => (
25-
<span data-testid={`tooltip-${entry.path}`}>{label}</span>
26-
),
27-
invertTooltipColors: index === 1, // Second item has inverted tooltip
28-
omitWrapping: index === 2, // Third item omits wrapping
29-
}))
11+
detailsEntries.reduce<Array<DetailsRowItem>>((acc, entry) => {
12+
if (!entry.isGroup) {
13+
acc.push({
14+
path: entry.path,
15+
label: entry.path,
16+
value: entry.value,
17+
icon: ({ size }: any) => (
18+
<span data-testid={`icon-${entry.path}`} data-size={size} />
19+
),
20+
renderValue: ({ value, isNegative }: any) => (
21+
<span
22+
data-testid={`field-${entry.path}`}
23+
data-negative={isNegative}
24+
>
25+
{value}
26+
</span>
27+
),
28+
renderTooltip: ({ label }: any) => (
29+
<span data-testid={`tooltip-${entry.path}`}>{label}</span>
30+
),
31+
invertTooltipColors: acc.length === 1, // Second item has inverted tooltip
32+
omitWrapping: acc.length === 2, // Third item omits wrapping
33+
});
34+
}
35+
return acc;
36+
}, [])
3037
)
3138
);
3239

0 commit comments

Comments
 (0)