forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainnetExecutionWarningModal.test.tsx
More file actions
52 lines (43 loc) · 2 KB
/
Copy pathMainnetExecutionWarningModal.test.tsx
File metadata and controls
52 lines (43 loc) · 2 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { MainnetExecutionWarningModal } from './MainnetExecutionWarningModal';
describe('MainnetExecutionWarningModal', () => {
it('does not render when isOpen is false', () => {
const { container } = render(
<MainnetExecutionWarningModal isOpen={false} onClose={vi.fn()} onConfirm={vi.fn()} />
);
expect(container).toBeEmptyDOMElement();
});
it('renders execution-specific copy when isOpen is true', () => {
render(
<MainnetExecutionWarningModal isOpen={true} onClose={vi.fn()} onConfirm={vi.fn()} />
);
// Verify it does not render "switch" language
expect(screen.queryByText(/Switch Network/i)).not.toBeInTheDocument();
expect(screen.queryByText(/Target/i)).not.toBeInTheDocument();
// Verify execution-specific copy
expect(screen.getByText('Mainnet Execution Warning')).toBeInTheDocument();
expect(screen.getByText(/You are about to execute a transaction on mainnet/i)).toBeInTheDocument();
// Verify the primary button reads "Confirm & Execute"
const confirmButton = screen.getByRole('button', { name: /Confirm & Execute/i });
expect(confirmButton).toBeInTheDocument();
});
it('calls onClose when Cancel is clicked', () => {
const handleClose = vi.fn();
render(
<MainnetExecutionWarningModal isOpen={true} onClose={handleClose} onConfirm={vi.fn()} />
);
const cancelButton = screen.getByRole('button', { name: /Cancel/i });
fireEvent.click(cancelButton);
expect(handleClose).toHaveBeenCalledOnce();
});
it('calls onConfirm when Confirm & Execute is clicked', () => {
const handleConfirm = vi.fn();
render(
<MainnetExecutionWarningModal isOpen={true} onClose={vi.fn()} onConfirm={handleConfirm} />
);
const confirmButton = screen.getByRole('button', { name: /Confirm & Execute/i });
fireEvent.click(confirmButton);
expect(handleConfirm).toHaveBeenCalledOnce();
});
});