|
@@ -5,13 +5,19 @@ import { AdvertisementTypeSelector } from '../../src/components/AdvertisementTyp
|
|
|
import { advertisementTypeClient } from '../../src/api/advertisementTypeClient'
|
|
import { advertisementTypeClient } from '../../src/api/advertisementTypeClient'
|
|
|
|
|
|
|
|
// Mock the advertisement type client
|
|
// Mock the advertisement type client
|
|
|
-vi.mock('../../src/api/advertisementTypeClient', () => ({
|
|
|
|
|
- advertisementTypeClient: {
|
|
|
|
|
|
|
+vi.mock('../../src/api/advertisementTypeClient', () => {
|
|
|
|
|
+ const advertisementTypeClient = {
|
|
|
index: {
|
|
index: {
|
|
|
$get: vi.fn(),
|
|
$get: vi.fn(),
|
|
|
},
|
|
},
|
|
|
- },
|
|
|
|
|
-}))
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ advertisementTypeClient,
|
|
|
|
|
+ advertisementTypeClientManager: {
|
|
|
|
|
+ get: vi.fn(() => advertisementTypeClient),
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
const mockAdvertisementTypes = {
|
|
const mockAdvertisementTypes = {
|
|
|
data: [
|
|
data: [
|
|
@@ -38,7 +44,7 @@ const TestWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<QueryClientProvider client={queryClient}>
|
|
<QueryClientProvider client={queryClient}>
|
|
|
- {children}
|
|
|
|
|
|
|
+ {children as any}
|
|
|
</QueryClientProvider>
|
|
</QueryClientProvider>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -84,7 +90,7 @@ describe('AdvertisementTypeSelector 集成测试', () => {
|
|
|
it('应该处理加载状态', () => {
|
|
it('应该处理加载状态', () => {
|
|
|
// Mock 延迟响应
|
|
// Mock 延迟响应
|
|
|
(advertisementTypeClient.index.$get as any).mockImplementation(
|
|
(advertisementTypeClient.index.$get as any).mockImplementation(
|
|
|
- () => new Promise(() => {}) // 永不解析的Promise
|
|
|
|
|
|
|
+ () => new Promise(() => { }) // 永不解析的Promise
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
render(
|
|
render(
|