• 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/PaginatedTable/TableView.generated.test.jsx
1
// src/components/PaginatedTable/TableView.generated.test.jsx
2

3
import React from 'react';
4
import { render } from '@testing-library/react';
5
import PaginatedTableView from './TableView';
6
import { TableContext } from '../../bento-core';
7

NEW
8
jest.mock('@material-ui/core', () => {
×
NEW
9
  const React = jest.requireActual('react');
×
10

11
  function GridMock({ children, ...props }) {
NEW
12
    return React.createElement(
×
13
      'div',
14
      { 'data-testid': 'grid', 'data-grid-props': JSON.stringify(props) },
15
      children
16
    );
17
  }
18

19
  function withStylesMock() {
NEW
20
    return Component =>
×
NEW
21
      function WithStylesMock(props) {
×
NEW
22
        return React.createElement(Component, {
×
23
          ...props,
24
          classes: { mockedClass: 'mockedClass' },
25
        });
26
      };
27
  }
28

NEW
29
  return {
×
30
    Grid: GridMock,
31
    withStyles: withStylesMock,
32
  };
33
});
34

NEW
35
jest.mock('../../bento-core', () => {
×
NEW
36
  const React = jest.requireActual('react');
×
NEW
37
  const TableContext = React.createContext({
×
38
    context: { mockedContext: true },
39
  });
40

NEW
41
  const TableView = jest.fn(props => {
×
NEW
42
    TableView.mock.calls.push([props]);
×
NEW
43
    return null;
×
44
  });
NEW
45
  TableView.mock = { calls: [] };
×
46

NEW
47
  const Wrapper = jest.fn(props => {
×
NEW
48
    Wrapper.mock.calls.push([props]);
×
NEW
49
    return React.createElement(
×
50
      'div',
51
      { 'data-testid': 'wrapper' },
52
      props.children
53
    );
54
  });
NEW
55
  Wrapper.mock = { calls: [] };
×
56

NEW
57
  return {
×
58
    __esModule: true,
59
    TableContext,
60
    TableView,
61
    Wrapper,
62
  };
63
});
64

NEW
65
jest.mock('./TableStyle', () => ({
×
66
  __esModule: true,
67
  default: { root: 'table-style' },
68
}));
69

NEW
70
jest.mock('./TableTheme', () => {
×
NEW
71
  const themeConfig = jest.fn((tabStyles, context) => {
×
NEW
72
    themeConfig.mock.calls.push([tabStyles, context]);
×
NEW
73
    return {
×
74
      tabStyles,
75
      context,
76
    };
77
  });
NEW
78
  themeConfig.mock = { calls: [] };
×
79

NEW
80
  return {
×
81
    __esModule: true,
82
    customTheme: { baseTheme: true },
83
    themeConfig,
84
  };
85
});
86

NEW
87
jest.mock('./Customize/CellView', () => {
×
NEW
88
  const CustomizeCellView = jest.fn(props => {
×
NEW
89
    CustomizeCellView.mock.calls.push([props]);
×
NEW
90
    return ['mock-column-1', 'mock-column-2'];
×
91
  });
NEW
92
  CustomizeCellView.mock = { calls: [] };
×
93

NEW
94
  return {
×
95
    __esModule: true,
96
    CustomizeCellView,
97
  };
98
});
99

NEW
100
jest.mock('./Customize/TableView', () => {
×
NEW
101
  const updateWrapperConfig = jest.fn(
×
102
    (config, tableLayOut, context, totalRowCount) => {
NEW
103
      updateWrapperConfig.mock.calls.push([
×
104
        config,
105
        tableLayOut,
106
        context,
107
        totalRowCount,
108
      ]);
NEW
109
      return {
×
110
        configName: config.name,
111
        tableLayOut,
112
        context,
113
        totalRowCount,
114
      };
115
    }
116
  );
NEW
117
  updateWrapperConfig.mock = { calls: [] };
×
118

NEW
119
  return {
×
120
    __esModule: true,
121
    updateWrapperConfig,
122
  };
123
});
124

NEW
125
jest.mock('./Customize/ExtendedView', () => {
×
NEW
126
  const ExtendedViewConfig = jest.fn(config => {
×
NEW
127
    ExtendedViewConfig.mock.calls.push([config]);
×
NEW
128
    return { extended: true };
×
129
  });
NEW
130
  ExtendedViewConfig.mock = { calls: [] };
×
131

NEW
132
  return {
×
133
    __esModule: true,
134
    ExtendedViewConfig,
135
  };
136
});
137

NEW
138
jest.mock('./Customize/ColumnGrouping', () => {
×
NEW
139
  const ColumnGrouping = jest.fn(columnGroups => {
×
NEW
140
    ColumnGrouping.mock.calls.push([columnGroups]);
×
NEW
141
    return ['group-1'];
×
142
  });
NEW
143
  ColumnGrouping.mock = { calls: [] };
×
144

NEW
145
  return {
×
146
    __esModule: true,
147
    ColumnGrouping,
148
  };
149
});
150

NEW
151
jest.mock('./Customize/PaginationOptions', () => {
×
NEW
152
  const paginationOptions = jest.fn((context, config) => {
×
NEW
153
    paginationOptions.mock.calls.push([context, config]);
×
NEW
154
    return ['page-10', 'page-20'];
×
155
  });
NEW
156
  paginationOptions.mock = { calls: [] };
×
157

NEW
158
  return {
×
159
    __esModule: true,
160
    paginationOptions,
161
  };
162
});
163

164
import { CustomizeCellView } from './Customize/CellView';
165
import { updateWrapperConfig } from './Customize/TableView';
166
import { ExtendedViewConfig } from './Customize/ExtendedView';
167
import { ColumnGrouping } from './Customize/ColumnGrouping';
168
import { paginationOptions } from './Customize/PaginationOptions';
169
import { themeConfig } from './TableTheme';
170
import {
171
  TableView as MockTableView,
172
  Wrapper as MockWrapper,
173
} from '../../bento-core';
174

NEW
175
describe('PaginatedTableView', () => {
×
NEW
176
  beforeEach(() => {
×
NEW
177
    jest.clearAllMocks();
×
178

NEW
179
    MockTableView.mock.calls = [];
×
NEW
180
    MockWrapper.mock.calls = [];
×
NEW
181
    themeConfig.mock.calls = [];
×
NEW
182
    CustomizeCellView.mock.calls = [];
×
NEW
183
    updateWrapperConfig.mock.calls = [];
×
NEW
184
    ExtendedViewConfig.mock.calls = [];
×
NEW
185
    ColumnGrouping.mock.calls = [];
×
NEW
186
    paginationOptions.mock.calls = [];
×
187
  });
188

NEW
189
  const baseConfig = {
×
190
    name: 'Cases',
191
    api: 'GET_CASES',
192
    paginationAPIField: 'subjectOverview',
193
    dataKey: 'subject_id',
194
    tableMsg: 'No cases found',
195
    defaultSortField: 'submitter_id',
196
    defaultSortDirection: 'asc',
197
    columnGroups: ['group-a'],
198
    tableID: 'cases-table',
199
  };
200

NEW
201
  it('renders Wrapper and TableView with core props', () => {
×
NEW
202
    const activeFilters = { program: ['ICDC'] };
×
NEW
203
    const tableReduxActions = { someAction: jest.fn() };
×
NEW
204
    const tabStyles = { head: { color: 'red' } };
×
NEW
205
    const contextValue = { context: { mockedContext: 'ctx' } };
×
206

NEW
207
    render(
×
208
      <TableContext.Provider value={contextValue}>
209
        <PaginatedTableView
210
          config={baseConfig}
211
          totalRowCount={42}
212
          activeFilters={activeFilters}
213
          activeTab="cases"
214
          tabStyles={tabStyles}
215
          tblRows={[{ id: 1 }]}
216
          isServer={false}
217
          classes={{}}
218
          tableLayOut={['left', 'right']}
219
          rowsPerPage={25}
220
          tableReduxActions={tableReduxActions}
221
        />
222
      </TableContext.Provider>
223
    );
224

NEW
225
    expect(updateWrapperConfig.mock.calls[0]).toEqual([
×
226
      baseConfig,
227
      ['left', 'right'],
228
      contextValue.context,
229
      42,
230
    ]);
231

232
    const wrapperProps =
NEW
233
      MockWrapper.mock.calls[MockWrapper.mock.calls.length - 1][0];
×
NEW
234
    expect(wrapperProps.section).toBe('Cases');
×
NEW
235
    expect(wrapperProps.activeFilters).toEqual(activeFilters);
×
236

NEW
237
    expect(themeConfig.mock.calls[0]).toEqual([
×
238
      tabStyles,
239
      contextValue.context,
240
    ]);
NEW
241
    expect(paginationOptions.mock.calls[0]).toEqual([
×
242
      contextValue.context,
243
      baseConfig,
244
    ]);
245

246
    const tableViewCall =
NEW
247
      MockTableView.mock.calls[MockTableView.mock.calls.length - 1][0];
×
NEW
248
    expect(tableViewCall.totalRowCount).toBe(42);
×
NEW
249
    expect(tableViewCall.activeTab).toBe('cases');
×
NEW
250
    expect(tableViewCall.tblRows).toEqual([{ id: 1 }]);
×
NEW
251
    expect(tableViewCall.server).toBe(false);
×
NEW
252
    expect(tableViewCall.queryVariables).toEqual(activeFilters);
×
NEW
253
    expect(tableViewCall.paginationOptions).toEqual(['page-10', 'page-20']);
×
254
  });
255

NEW
256
  it('passes the initState function with expected derived values', () => {
×
NEW
257
    const tableReduxActions = { someAction: jest.fn() };
×
258

NEW
259
    render(
×
260
      <TableContext.Provider value={{ context: { mockedContext: true } }}>
261
        <PaginatedTableView
262
          config={baseConfig}
263
          totalRowCount={7}
264
          activeFilters={{}}
265
          activeTab="cases"
266
          tabStyles={{}}
267
          tblRows={[]}
268
          isServer
269
          classes={{}}
270
          tableReduxActions={tableReduxActions}
271
        />
272
      </TableContext.Provider>
273
    );
274

275
    const tableViewCall =
NEW
276
      MockTableView.mock.calls[MockTableView.mock.calls.length - 1][0];
×
NEW
277
    expect(typeof tableViewCall.initState).toBe('function');
×
278

NEW
279
    const initStateResult = tableViewCall.initState({
×
280
      customKey: 'customValue',
281
    });
282

NEW
283
    expect(initStateResult).toEqual(
×
284
      expect.objectContaining({
285
        customKey: 'customValue',
286
        title: baseConfig.name,
287
        query: baseConfig.api,
288
        paginationAPIField: baseConfig.paginationAPIField,
289
        dataKey: baseConfig.dataKey,
290
        columns: ['mock-column-1', 'mock-column-2'],
291
        count: 7,
292
        selectedRows: [],
293
        selectedFileIds: [],
294
        tableMsg: baseConfig.tableMsg,
295
        sortBy: baseConfig.defaultSortField,
296
        sortOrder: baseConfig.defaultSortDirection,
297
        extendedViewConfig: { extended: true },
298
        columnGroups: ['group-1'],
299
        rowsPerPage: 10,
300
        page: 0,
301
      })
302
    );
303
  });
304

NEW
305
  it('calls overriedTableState when provided', () => {
×
NEW
306
    const overriedTableState = jest.fn();
×
307

NEW
308
    render(
×
309
      <TableContext.Provider value={{ context: { mockedContext: 'ctx' } }}>
310
        <PaginatedTableView
311
          config={baseConfig}
312
          totalRowCount={1}
313
          activeFilters={{}}
314
          activeTab="cases"
315
          tabStyles={{}}
316
          tblRows={[]}
317
          isServer
318
          classes={{}}
319
          overriedTableState={overriedTableState}
320
        />
321
      </TableContext.Provider>
322
    );
323

NEW
324
    expect(overriedTableState).toHaveBeenCalled();
×
NEW
325
    expect(
×
326
      overriedTableState.mock.calls[overriedTableState.mock.calls.length - 1][0]
327
    ).toEqual({
328
      mockedContext: 'ctx',
329
    });
330
  });
331
});
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