feat: 全局资产库直接展示全部图片
This commit is contained in:
@@ -20,6 +20,19 @@ const asset: ProjectAsset = {
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('项目资产 API', () => {
|
||||
it('通过单个全局接口读取全部项目素材', async () => {
|
||||
const globalAsset = {
|
||||
...asset,
|
||||
project: { id: 'project-db-1', title: '记忆当铺', topic: '记忆交易', status: 'completed' }
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(new Response(JSON.stringify({ data: [globalAsset] })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
|
||||
await expect(projectAssetsApi.listAll()).resolves.toEqual([globalAsset])
|
||||
expect(fetcher).toHaveBeenCalledOnce()
|
||||
expect(fetcher).toHaveBeenCalledWith('/api/assets', expect.objectContaining({ method: 'GET' }))
|
||||
})
|
||||
|
||||
it('使用 multipart 上传文件,不手工设置 Content-Type', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
|
||||
Reference in New Issue
Block a user