1
This commit is contained in:
52
src/services/puzzle-gallery/puzzleGalleryClient.test.ts
Normal file
52
src/services/puzzle-gallery/puzzleGalleryClient.test.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { beforeEach, expect, test, vi } from 'vitest';
|
||||
|
||||
const { requestJsonMock } = vi.hoisted(() => ({
|
||||
requestJsonMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../apiClient', () => ({
|
||||
requestJson: requestJsonMock,
|
||||
}));
|
||||
|
||||
import { getPuzzleGalleryDetail, listPuzzleGallery } from './puzzleGalleryClient';
|
||||
|
||||
beforeEach(() => {
|
||||
requestJsonMock.mockReset();
|
||||
requestJsonMock.mockResolvedValue({ items: [] });
|
||||
});
|
||||
|
||||
test('listPuzzleGallery reads public gallery without auth refresh coupling', async () => {
|
||||
await listPuzzleGallery();
|
||||
|
||||
expect(requestJsonMock).toHaveBeenCalledWith(
|
||||
'/api/runtime/puzzle/gallery',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
'读取拼图广场失败',
|
||||
expect.objectContaining({
|
||||
retry: expect.objectContaining({ maxRetries: 1 }),
|
||||
skipAuth: true,
|
||||
skipRefresh: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('getPuzzleGalleryDetail reads public detail without auth refresh coupling', async () => {
|
||||
requestJsonMock.mockResolvedValueOnce({
|
||||
item: {
|
||||
profileId: 'puzzle-profile-1',
|
||||
},
|
||||
});
|
||||
|
||||
await getPuzzleGalleryDetail('puzzle-profile-1');
|
||||
|
||||
expect(requestJsonMock).toHaveBeenCalledWith(
|
||||
'/api/runtime/puzzle/gallery/puzzle-profile-1',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
'读取拼图广场详情失败',
|
||||
expect.objectContaining({
|
||||
retry: expect.objectContaining({ maxRetries: 1 }),
|
||||
skipAuth: true,
|
||||
skipRefresh: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user