• 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/StudyLink.generated.test.jsx
1
// src/components/PaginatedTable/Customize/components/StudyLink.test.jsx
2
import React from 'react';
3
import { render, screen } from '@testing-library/react';
4
import StudyLink from './StudyLink';
5

6
// Mock bento-core to provide a deterministic LINK class
NEW
7
jest.mock('../../../../bento-core', () => ({
×
8
  cellTypes: { LINK: 'bento-link' },
9
}));
10

11
// Mock studyDisposition to be controllable and safe for undefined/null
NEW
12
const mockStudyDisposition = jest.fn(value => value);
×
NEW
13
jest.mock('../DataAvailability/TableCell', () => ({
×
NEW
14
  studyDisposition: value => mockStudyDisposition(value),
×
15
}));
16

17
// Mock getStudyIcon to be controllable
NEW
18
const mockGetStudyIcon = jest.fn(() => false);
×
NEW
19
jest.mock('./NumberOfCases', () => ({
×
NEW
20
  getStudyIcon: (...args) => mockGetStudyIcon(...args),
×
21
}));
22

NEW
23
describe('StudyLink component', () => {
×
NEW
24
  const defaultProps = {
×
25
    clinical_study_designation: 'ICDC-TEST',
26
    study_disposition: 'under embargo',
27
    accession_id: 'ACC-123',
28
    program: 'DOG',
29
    linkAttr: {
30
      rootPath: 'studies',
31
      pathParams: ['accession_id', 'program'],
32
    },
33
  };
34

NEW
35
  beforeEach(() => {
×
NEW
36
    jest.clearAllMocks();
×
37
  });
38

NEW
39
  test('renders link with study designation text and LINK class when icon is not returned (happy path)', () => {
×
NEW
40
    mockGetStudyIcon.mockReturnValueOnce(false);
×
NEW
41
    mockStudyDisposition.mockImplementationOnce(value => value);
×
42

NEW
43
    render(<StudyLink {...defaultProps} />);
×
44

NEW
45
    const link = screen.getByRole('link', { name: /ICDC-TEST/i });
×
NEW
46
    expect(link).toBeTruthy();
×
47

48
    // href is created by mapping pathParams to ["#studies/ACC-123", "#studies/DOG"]
49
    // React/DOM sets attribute to comma-separated string for an array value
NEW
50
    expect(link.getAttribute('href')).toBe('#studies/ACC-123,#studies/DOG');
×
51

52
    // Ensure class from cellTypes is applied
NEW
53
    expect(link.classList.contains('bento-link')).toBe(true);
×
54

55
    // No icon should be present
NEW
56
    expect(screen.queryByTestId('study-icon')).toBeNull();
×
57

58
    // Ensure getStudyIcon called with transformed disposition
NEW
59
    expect(mockStudyDisposition).toHaveBeenCalledWith('under embargo');
×
NEW
60
    expect(mockGetStudyIcon).toHaveBeenCalledWith(
×
61
      expect.any(Object),
62
      'under embargo'
63
    );
64
  });
65

NEW
66
  test('renders StudyIcon when getStudyIcon returns an element', () => {
×
NEW
67
    mockStudyDisposition.mockImplementationOnce(() => 'embargo');
×
68
    // Return a deterministic icon element
NEW
69
    mockGetStudyIcon.mockImplementationOnce(() =>
×
NEW
70
      React.createElement('span', { 'data-testid': 'study-icon' }, 'ICON')
×
71
    );
72

NEW
73
    render(<StudyLink {...defaultProps} />);
×
74

NEW
75
    const link = screen.getByRole('link', { name: /ICDC-TEST/i });
×
NEW
76
    expect(link).toBeTruthy();
×
77

78
    // Icon should be present
NEW
79
    expect(screen.getByTestId('study-icon')).toBeTruthy();
×
80

NEW
81
    expect(mockGetStudyIcon).toHaveBeenCalledWith(
×
82
      expect.any(Object),
83
      'embargo'
84
    );
85
  });
86

NEW
87
  test('constructs empty href when pathParams is empty (edge case)', () => {
×
NEW
88
    mockGetStudyIcon.mockReturnValueOnce(false);
×
NEW
89
    mockStudyDisposition.mockImplementationOnce(v => v);
×
90

NEW
91
    const props = {
×
92
      ...defaultProps,
93
      linkAttr: { rootPath: 'studies', pathParams: [] },
94
    };
95

NEW
96
    render(<StudyLink {...props} />);
×
97

NEW
98
    const link = screen.getByRole('link', { name: /ICDC-TEST/i });
×
NEW
99
    expect(link).toBeTruthy();
×
100
    // Empty array as href yields empty string on the DOM attribute
NEW
101
    expect(link.getAttribute('href')).toBe('');
×
102
  });
103

NEW
104
  test('handles missing props for a requested path param by producing undefined in href (invalid input)', () => {
×
NEW
105
    mockGetStudyIcon.mockReturnValueOnce(false);
×
NEW
106
    mockStudyDisposition.mockImplementationOnce(v => v);
×
107

NEW
108
    const props = {
×
109
      ...defaultProps,
110
      // Remove "program" from props so it becomes undefined in URL
111
      program: undefined,
112
    };
113

NEW
114
    render(<StudyLink {...props} />);
×
115

NEW
116
    const link = screen.getByRole('link', { name: /ICDC-TEST/i });
×
NEW
117
    expect(link).toBeTruthy();
×
118
    // Array becomes "#studies/ACC-123,#studies/undefined"
NEW
119
    expect(link.getAttribute('href')).toBe(
×
120
      '#studies/ACC-123,#studies/undefined'
121
    );
122
  });
123

NEW
124
  test('does not render icon and does not crash when study_disposition is undefined (null/undefined case)', () => {
×
NEW
125
    mockStudyDisposition.mockImplementationOnce(() => undefined);
×
NEW
126
    mockGetStudyIcon.mockReturnValueOnce(false);
×
127

NEW
128
    const props = {
×
129
      ...defaultProps,
130
      study_disposition: undefined,
131
    };
132

NEW
133
    render(<StudyLink {...props} />);
×
134

135
    // Link still present
NEW
136
    const link = screen.getByRole('link', { name: /ICDC-TEST/i });
×
NEW
137
    expect(link).toBeTruthy();
×
138
    // No icon rendered
NEW
139
    expect(screen.queryByTestId('study-icon')).toBeNull();
×
140

NEW
141
    expect(mockGetStudyIcon).toHaveBeenCalledWith(
×
142
      expect.any(Object),
143
      undefined
144
    );
145
  });
146
});
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