-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathNewBrowserWindow.test.jsx
More file actions
34 lines (30 loc) · 950 Bytes
/
NewBrowserWindow.test.jsx
File metadata and controls
34 lines (30 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { render } from '@tests/utils/test-utils';
import { NewBrowserWindow } from '../../../src/components/NewBrowserWindow';
/**
* Helper function to create a shallow wrapper around ErrorDialog
*/
function createWrapper(props) {
return render(
<NewBrowserWindow
url="http://example.com/"
onClose={() => {}}
{...props}
/>,
);
}
describe('NewBrowserWindow', () => {
it('renders properly and runs callbacks when the window closes', () => {
const mockWindow = { close: vi.fn() };
const open = vi.fn(() => mockWindow);
const onClose = vi.fn();
vi.useFakeTimers();
createWrapper({ depWindow: { open }, onClose });
expect(open).toHaveBeenCalledWith('http://example.com/', undefined, undefined);
vi.runOnlyPendingTimers();
expect(onClose).not.toBeCalled();
mockWindow.closed = true;
vi.runOnlyPendingTimers();
expect(onClose).toBeCalled();
vi.useRealTimers();
});
});