• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / bento-icdc-frontend / 26519274266

27 May 2026 02:57PM UTC coverage: 17.458% (-8.3%) from 25.73%
26519274266

push

github

web-flow
Merge pull request #1606 from CBIIT/feature/ai-test-studio

core components unit test

306 of 2587 branches covered (11.83%)

Branch coverage included in aggregate %.

1 of 4244 new or added lines in 74 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11750 relevant lines covered (18.7%)

0.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/PaginatedTable/Customize/components/multiStudyTooltip.generated.test.jsx
1
// File: src/components/PaginatedTable/Customize/components/multiStudyTooltip.test.jsx
2

3
import React from 'react';
4
import { render, screen, within } from '@testing-library/react';
5

NEW
6
const mockReact = React;
×
7

8
// Mock bento-core's ToolTip so the component renders deterministically
NEW
9
jest.mock('../../../../bento-core', () => {
×
NEW
10
  const MockToolTip = ({ title, children }) =>
×
NEW
11
    mockReact.createElement(
×
12
      'div',
13
      { 'data-testid': 'mock-tooltip' },
14
      mockReact.createElement('div', { 'data-testid': 'tooltip-title' }, title),
15
      children
16
    );
17

NEW
18
  return { ToolTip: MockToolTip };
×
19
});
20

21
// Mock dashboardTabData to keep icon/text stable
NEW
22
jest.mock('../../../../bento/dashboardTabData', () => ({
×
23
  multiStudyData: {
24
    icon: 'mock-icon.png',
25
    alt: 'mock-multi-study-icon',
26
    toolTipText: 'Mock: Multi-study participant also enrolled as:',
27
  },
28
}));
29

30
import MultiStudyToolTip from './multiStudyTooltip';
31

NEW
32
describe('MultiStudyToolTip', () => {
×
NEW
33
  it('renders icon, counter (length + 1), tooltip text, case links, and unified view link (happy path)', () => {
×
NEW
34
    const tableMeta = ['CASE-1', 'CASE-2'];
×
NEW
35
    const value = 'PARENT-CASE-ID';
×
36

NEW
37
    render(<MultiStudyToolTip tableMeta={tableMeta} value={value} />);
×
38

NEW
39
    const img = screen.getByAltText('mock-multi-study-icon');
×
NEW
40
    expect(img).toBeTruthy();
×
NEW
41
    expect(img.getAttribute('src')).toBe('mock-icon.png');
×
42

NEW
43
    expect(screen.getByText('3')).toBeTruthy();
×
44

NEW
45
    const tooltip = screen.getByTestId('mock-tooltip');
×
NEW
46
    expect(
×
47
      within(tooltip).getByText(
48
        'Mock: Multi-study participant also enrolled as:'
49
      )
50
    ).toBeTruthy();
51

NEW
52
    const case1Link = within(tooltip).getByText('Case: CASE-1').closest('a');
×
NEW
53
    const case2Link = within(tooltip).getByText('Case: CASE-2').closest('a');
×
NEW
54
    expect(case1Link.getAttribute('href')).toBe('/#/case/CASE-1');
×
NEW
55
    expect(case2Link.getAttribute('href')).toBe('/#/case/CASE-2');
×
56

NEW
57
    const viewAllLink = within(tooltip)
×
58
      .getByText('View All Related Cases')
59
      .closest('a');
NEW
60
    expect(viewAllLink.getAttribute('href')).toBe(
×
61
      '/#/unifiedView/PARENT-CASE-ID'
62
    );
63
  });
64

NEW
65
  it('renders correctly with an empty tableMeta (edge case)', () => {
×
NEW
66
    const tableMeta = [];
×
NEW
67
    const value = 'SINGLE-ID';
×
68

NEW
69
    render(<MultiStudyToolTip tableMeta={tableMeta} value={value} />);
×
70

NEW
71
    expect(screen.getByText('1')).toBeTruthy();
×
72

NEW
73
    const tooltip = screen.getByTestId('mock-tooltip');
×
NEW
74
    expect(within(tooltip).queryByText(/^Case:/)).toBeNull();
×
75

NEW
76
    const unifiedLink = within(tooltip)
×
77
      .getByText('View All Related Cases')
78
      .closest('a');
NEW
79
    expect(unifiedLink.getAttribute('href')).toBe('/#/unifiedView/SINGLE-ID');
×
80
  });
81

NEW
82
  it('renders unified view link with "undefined" when value prop is missing (invalid input scenario)', () => {
×
NEW
83
    const tableMeta = ['ONLY-CASE'];
×
84

NEW
85
    render(<MultiStudyToolTip tableMeta={tableMeta} />);
×
86

NEW
87
    const tooltip = screen.getByTestId('mock-tooltip');
×
NEW
88
    const unifiedLink = within(tooltip)
×
89
      .getByText('View All Related Cases')
90
      .closest('a');
NEW
91
    expect(unifiedLink.getAttribute('href')).toBe('/#/unifiedView/undefined');
×
92
  });
93

NEW
94
  it('throws error if tableMeta is undefined (error handling)', () => {
×
NEW
95
    expect(() =>
×
NEW
96
      render(<MultiStudyToolTip tableMeta={undefined} value="X" />)
×
97
    ).toThrow();
98
  });
99

NEW
100
  it('renders the same number of "Case:" links as items in tableMeta (boundary check)', () => {
×
NEW
101
    const tableMeta = ['A', 'B', 'C', 'D'];
×
102

NEW
103
    render(<MultiStudyToolTip tableMeta={tableMeta} value="P" />);
×
104

NEW
105
    const tooltip = screen.getByTestId('mock-tooltip');
×
NEW
106
    const caseLabels = within(tooltip).getAllByText(/^Case:/);
×
NEW
107
    const caseLinks = caseLabels.map(node => node.closest('a'));
×
108

NEW
109
    expect(caseLinks).toHaveLength(tableMeta.length);
×
NEW
110
    expect(caseLinks.map(a => a.getAttribute('href'))).toEqual([
×
111
      '/#/case/A',
112
      '/#/case/B',
113
      '/#/case/C',
114
      '/#/case/D',
115
    ]);
116
  });
117
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc