• 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/AddToCartDialog/AddToCartDialogAlertView.generated.test.jsx
1
import React from 'react';
2
import { render, screen, cleanup, act } from '@testing-library/react';
3
import AddToCartDialogAlertView from './AddToCartDialogAlertView';
4

NEW
5
jest.mock('./dialogThemeConfig', () => ({
×
6
  __esModule: true,
NEW
7
  default: ({ children }) => <>{children}</>,
×
8
}));
9

NEW
10
jest.mock('@material-ui/core', () => ({
×
11
  __esModule: true,
12
  Dialog: ({ children, open, className, ...rest }) =>
NEW
13
    open ? (
×
14
      <div data-testid="dialog" className={className} {...rest}>
15
        {children}
16
      </div>
17
    ) : null,
18
  DialogContent: ({ children, className, ...rest }) => (
NEW
19
    <div data-testid="dialog-content" className={className} {...rest}>
×
20
      {children}
21
    </div>
22
  ),
NEW
23
  DialogContentText: ({ children, ...rest }) => <p {...rest}>{children}</p>,
×
24
}));
25

NEW
26
describe('AddToCartDialogAlertView', () => {
×
27
  const alertMessage =
NEW
28
    'The cart is limited to 2,000 files. Please narrow the search criteria or remove some files from the cart to add more.';
×
29

NEW
30
  const classes = {
×
31
    popUpWindow: 'test-popup-window',
32
    popUpWindowContent: 'test-popup-window-content',
33
  };
34

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

NEW
40
  afterEach(() => {
×
NEW
41
    cleanup();
×
NEW
42
    jest.clearAllTimers();
×
NEW
43
    jest.useRealTimers();
×
NEW
44
    jest.restoreAllMocks();
×
45
  });
46

NEW
47
  it('does not render the alert message when open is false', () => {
×
NEW
48
    render(
×
49
      <AddToCartDialogAlertView
50
        open={false}
51
        classes={classes}
52
        onClose={jest.fn()}
53
      />
54
    );
55

NEW
56
    expect(screen.queryByText(alertMessage)).toBeNull();
×
57
  });
58

NEW
59
  it('renders the alert message when open is true', () => {
×
NEW
60
    render(
×
61
      <AddToCartDialogAlertView open classes={classes} onClose={jest.fn()} />
62
    );
63

NEW
64
    expect(screen.getByText(alertMessage)).not.toBeNull();
×
65
  });
66

NEW
67
  it('applies the provided class names to Dialog and DialogContent', () => {
×
NEW
68
    render(
×
69
      <AddToCartDialogAlertView open classes={classes} onClose={jest.fn()} />
70
    );
71

NEW
72
    expect(screen.getByTestId('dialog').className).toContain(
×
73
      'test-popup-window'
74
    );
NEW
75
    expect(screen.getByTestId('dialog-content').className).toContain(
×
76
      'test-popup-window-content'
77
    );
78
  });
79

NEW
80
  it('calls onClose exactly once after 4000ms when open is true', () => {
×
NEW
81
    jest.useFakeTimers();
×
NEW
82
    const onClose = jest.fn();
×
83

NEW
84
    render(
×
85
      <AddToCartDialogAlertView open classes={classes} onClose={onClose} />
86
    );
87

NEW
88
    expect(onClose).not.toHaveBeenCalled();
×
89

NEW
90
    act(() => {
×
NEW
91
      jest.advanceTimersByTime(3999);
×
92
    });
NEW
93
    expect(onClose).not.toHaveBeenCalled();
×
94

NEW
95
    act(() => {
×
NEW
96
      jest.advanceTimersByTime(1);
×
97
    });
NEW
98
    expect(onClose).toHaveBeenCalledTimes(1);
×
99
  });
100

NEW
101
  it('does not schedule close when open is false', () => {
×
NEW
102
    jest.useFakeTimers();
×
NEW
103
    const onClose = jest.fn();
×
NEW
104
    const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
×
105

NEW
106
    render(
×
107
      <AddToCartDialogAlertView
108
        open={false}
109
        classes={classes}
110
        onClose={onClose}
111
      />
112
    );
113

NEW
114
    expect(setTimeoutSpy).not.toHaveBeenCalled();
×
115

NEW
116
    act(() => {
×
NEW
117
      jest.runOnlyPendingTimers();
×
118
    });
119

NEW
120
    expect(onClose).not.toHaveBeenCalled();
×
121
  });
122

NEW
123
  it('schedules a timeout for 4000ms when open is true', () => {
×
NEW
124
    jest.useFakeTimers();
×
NEW
125
    const onClose = jest.fn();
×
NEW
126
    const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
×
127

NEW
128
    render(
×
129
      <AddToCartDialogAlertView open classes={classes} onClose={onClose} />
130
    );
131

NEW
132
    expect(setTimeoutSpy).toHaveBeenCalledTimes(1);
×
133

NEW
134
    const [callback, delay] = setTimeoutSpy.mock.calls[0];
×
NEW
135
    expect(typeof callback).toBe('function');
×
NEW
136
    expect(delay).toBe(4000);
×
137
  });
138
});
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