AccountList.test.tsx
1 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
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import AccountList from '../pages/Accounts/AccountList';
vi.mock('../stores/accountStore', () => ({
useAccountStore: vi.fn(() => ({
accounts: [],
total: 0,
page: 1,
pageSize: 20,
totalPages: 0,
loading: false,
fetchAccounts: vi.fn(),
createAccount: vi.fn(),
updateAccount: vi.fn(),
toggleAccountStatus: vi.fn(),
})),
}));
vi.mock('../stores/providerStore', () => ({
useProviderStore: vi.fn(() => ({
providers: [],
total: 0,
page: 1,
pageSize: 20,
totalPages: 0,
loading: false,
fetchProviders: vi.fn(),
})),
}));
describe('AccountList', () => {
it('渲染账号配置页面标题', () => {
render(<AccountList />);
expect(screen.getByText('账号配置')).toBeInTheDocument();
});
it('渲染新增账号按钮', () => {
render(<AccountList />);
expect(screen.getByText('新增账号')).toBeInTheDocument();
});
});