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

CBIIT / bento-icdc-frontend / 26531437966

27 May 2026 06:43PM UTC coverage: 17.253% (-8.5%) from 25.73%
26531437966

Pull #1607

github

web-flow
Merge 8713d05ca into bc935f39c
Pull Request #1607: Feature/ai test studio - ICDC-4165 & ICDC-4171

306 of 2599 branches covered (11.77%)

Branch coverage included in aggregate %.

1 of 4403 new or added lines in 76 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11909 relevant lines covered (18.45%)

0.41 hits per line

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

0.0
/src/components/Stats/StatsView.generated.test.jsx
1
// src/components/Stats/StatsView.test.jsx
2
import React from 'react';
3
import { render } from '@testing-library/react';
4

5
// Mock StatsBar from bento-core to avoid rendering the real component and to inspect props
NEW
6
const mockStatsBar = jest.fn(() => null);
×
NEW
7
jest.mock('../../bento-core', () => ({
×
NEW
8
  StatsBar: (...args) => mockStatsBar(...args),
×
9
}));
10

11
// Mock globalStatsData and statsStyling to be deterministic
NEW
12
jest.mock('../../bento/globalStatsData', () => ({
×
13
  globalStatsData: [
14
    {
15
      statTitle: 'Programs',
16
      statAPI: 'numberOfPrograms',
17
      statIconSrc: 'programs-icon.svg',
18
    },
19
    {
20
      statTitle: 'Studies',
21
      statAPI: 'numberOfStudies',
22
      statIconSrc: 'studies-icon.svg',
23
    },
24
    {
25
      statTitle: 'Data Volume',
26
      statAPI: 'volumeOfData',
27
      statIconSrc: 'data-volume-icon.svg',
28
    },
29
  ],
30
  statsStyling: { global: { horizontalStyle: true } },
31
}));
32

33
// Mock updateStat so we can control output and errors
NEW
34
const mockUpdateStat = jest.fn();
×
NEW
35
jest.mock('./utils', () => ({
×
NEW
36
  updateStat: (...args) => mockUpdateStat(...args),
×
37
}));
38

39
// Import after mocks so the component uses the mocked modules
40
import StatsView from './StatsView';
41

NEW
42
describe('StatsView', () => {
×
NEW
43
  beforeEach(() => {
×
NEW
44
    jest.clearAllMocks();
×
45
  });
46

NEW
47
  it('should render StatsBar with mapped stats and provided styles (happy path)', () => {
×
NEW
48
    const inputData = { some: 'input' };
×
NEW
49
    const transformedData = {
×
50
      numberOfPrograms: 5,
51
      numberOfStudies: 12,
52
      volumeOfData: '3.2 GB',
53
    };
NEW
54
    mockUpdateStat.mockReturnValue(transformedData);
×
55

NEW
56
    render(<StatsView data={inputData} />);
×
57

NEW
58
    expect(mockUpdateStat).toHaveBeenCalledTimes(1);
×
NEW
59
    expect(mockUpdateStat).toHaveBeenCalledWith(inputData);
×
60

NEW
61
    expect(mockStatsBar).toHaveBeenCalledTimes(1);
×
NEW
62
    const propsPassed = mockStatsBar.mock.calls[0][0];
×
63

NEW
64
    expect(propsPassed.styles).toEqual({ global: { horizontalStyle: true } });
×
65

NEW
66
    expect(propsPassed.stats).toEqual([
×
67
      {
68
        name: 'Programs',
69
        val: 5,
70
        statIconSrc: 'programs-icon.svg',
71
        statIconAlt: 'Programs-icon',
72
      },
73
      {
74
        name: 'Studies',
75
        val: 12,
76
        statIconSrc: 'studies-icon.svg',
77
        statIconAlt: 'Studies-icon',
78
      },
79
      {
80
        name: 'Data Volume',
81
        val: '3.2 GB',
82
        statIconSrc: 'data-volume-icon.svg',
83
        statIconAlt: 'Data Volume-icon',
84
      },
85
    ]);
86
  });
87

NEW
88
  it('should handle missing fields from updateStat by passing undefined values', () => {
×
NEW
89
    const inputData = { other: 'data' };
×
NEW
90
    const transformedData = {
×
91
      numberOfPrograms: 2,
92
      volumeOfData: '10 MB',
93
    };
NEW
94
    mockUpdateStat.mockReturnValue(transformedData);
×
95

NEW
96
    render(<StatsView data={inputData} />);
×
97

NEW
98
    expect(mockStatsBar).toHaveBeenCalledTimes(1);
×
NEW
99
    const propsPassed = mockStatsBar.mock.calls[0][0];
×
100

NEW
101
    expect(propsPassed.stats).toEqual([
×
102
      {
103
        name: 'Programs',
104
        val: 2,
105
        statIconSrc: 'programs-icon.svg',
106
        statIconAlt: 'Programs-icon',
107
      },
108
      {
109
        name: 'Studies',
110
        val: undefined,
111
        statIconSrc: 'studies-icon.svg',
112
        statIconAlt: 'Studies-icon',
113
      },
114
      {
115
        name: 'Data Volume',
116
        val: '10 MB',
117
        statIconSrc: 'data-volume-icon.svg',
118
        statIconAlt: 'Data Volume-icon',
119
      },
120
    ]);
121
  });
122

NEW
123
  it('throws error if updateStat throws (error path)', () => {
×
NEW
124
    const boom = new Error('boom');
×
NEW
125
    mockUpdateStat.mockImplementation(() => {
×
NEW
126
      throw boom;
×
127
    });
128

NEW
129
    expect(() => render(<StatsView data={{}} />)).toThrow(boom);
×
NEW
130
    expect(mockStatsBar).not.toHaveBeenCalled();
×
131
  });
132

NEW
133
  it('should call updateStat with null and render undefined stats when it returns an empty object', () => {
×
NEW
134
    mockUpdateStat.mockReturnValue({});
×
135

NEW
136
    render(<StatsView data={null} />);
×
137

NEW
138
    expect(mockUpdateStat).toHaveBeenCalledTimes(1);
×
NEW
139
    expect(mockUpdateStat).toHaveBeenCalledWith(null);
×
NEW
140
    expect(mockStatsBar).toHaveBeenCalledTimes(1);
×
141

NEW
142
    const propsPassed = mockStatsBar.mock.calls[0][0];
×
NEW
143
    expect(propsPassed.stats).toEqual([
×
144
      {
145
        name: 'Programs',
146
        val: undefined,
147
        statIconSrc: 'programs-icon.svg',
148
        statIconAlt: 'Programs-icon',
149
      },
150
      {
151
        name: 'Studies',
152
        val: undefined,
153
        statIconSrc: 'studies-icon.svg',
154
        statIconAlt: 'Studies-icon',
155
      },
156
      {
157
        name: 'Data Volume',
158
        val: undefined,
159
        statIconSrc: 'data-volume-icon.svg',
160
        statIconAlt: 'Data Volume-icon',
161
      },
162
    ]);
163
  });
164
});
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