228cadf526
Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import RightClickRestorerPage from '../index';
|
|
|
|
const mockUnlock = vi.fn();
|
|
|
|
vi.mock('../useRightClickRestorer', () => ({
|
|
useRightClickRestorer: () => ({
|
|
domain: 'example.com',
|
|
isLoading: false,
|
|
status: 'locked',
|
|
unlock: mockUnlock,
|
|
}),
|
|
}));
|
|
|
|
describe('RightClickRestorerPage', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('should render current domain', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/example\.com/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render locked status', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/未解锁/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should call unlock when button clicked', () => {
|
|
render(<RightClickRestorerPage />);
|
|
const button = screen.getByRole('button');
|
|
fireEvent.click(button);
|
|
expect(mockUnlock).toHaveBeenCalled();
|
|
});
|
|
});
|