1
This commit is contained in:
@@ -14,7 +14,7 @@ vi.mock('../apiClient', async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
import { listBigFishGallery } from './bigFishGalleryClient';
|
||||
import { likeBigFishGalleryWork, listBigFishGallery } from './bigFishGalleryClient';
|
||||
|
||||
beforeEach(() => {
|
||||
requestJsonMock.mockReset();
|
||||
@@ -42,3 +42,15 @@ test('listBigFishGallery keeps non-gallery-read errors visible', async () => {
|
||||
|
||||
await expect(listBigFishGallery()).rejects.toBe(error);
|
||||
});
|
||||
|
||||
test('likeBigFishGalleryWork posts to authenticated like route', async () => {
|
||||
requestJsonMock.mockResolvedValueOnce({ items: [] });
|
||||
|
||||
await likeBigFishGalleryWork('big-fish-session-1');
|
||||
|
||||
expect(requestJsonMock).toHaveBeenCalledWith(
|
||||
'/api/runtime/big-fish/gallery/big-fish-session-1/like',
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
'点赞大鱼吃小鱼作品失败',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -50,7 +50,21 @@ export async function remixBigFishGalleryWork(sessionId: string) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞公开大鱼吃小鱼作品,后端按当前登录用户做幂等计数。
|
||||
*/
|
||||
export async function likeBigFishGalleryWork(sessionId: string) {
|
||||
return requestJson<BigFishWorksResponse>(
|
||||
`${BIG_FISH_GALLERY_API_BASE}/${encodeURIComponent(sessionId)}/like`,
|
||||
{
|
||||
method: 'POST',
|
||||
},
|
||||
'点赞大鱼吃小鱼作品失败',
|
||||
);
|
||||
}
|
||||
|
||||
export const bigFishGalleryClient = {
|
||||
like: likeBigFishGalleryWork,
|
||||
list: listBigFishGallery,
|
||||
remix: remixBigFishGalleryWork,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export {
|
||||
bigFishGalleryClient,
|
||||
likeBigFishGalleryWork,
|
||||
listBigFishGallery,
|
||||
remixBigFishGalleryWork,
|
||||
} from './bigFishGalleryClient';
|
||||
|
||||
Reference in New Issue
Block a user