适配H5讲解统一详情接口
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-08-05 14:52:36 +08:00
parent c287ef3a2a
commit 2edb6bd9f2
25 changed files with 946 additions and 1148 deletions

View File

@@ -0,0 +1,37 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { explainUseCase } from '@/usecases/explainUseCase'
import { PoiDetailUseCase } from '@/usecases/poiDetailUseCase'
vi.mock('@/usecases/explainUseCase', () => ({
explainUseCase: {
getExhibitById: vi.fn(),
listHalls: vi.fn()
}
}))
describe('PoiDetailUseCase', () => {
beforeEach(() => {
vi.mocked(explainUseCase.getExhibitById).mockReset()
})
it('resolves a POI exhibit reference to a guide stop before opening the unified detail route', async () => {
vi.mocked(explainUseCase.getExhibitById).mockResolvedValue({
id: 'stop-865546647764037632',
resolvedStopId: '865546647764037632'
} as never)
const target = await new PoiDetailUseCase().resolve({
id: 'poi-1',
name: '青铜神树',
floorId: 'floor-1',
exhibitId: 'exhibit-1'
})
const params = new URLSearchParams(target.url.split('?')[1])
expect(explainUseCase.getExhibitById).toHaveBeenCalledWith('exhibit-1')
expect(target.detailId).toBe('865546647764037632')
expect(target.stopId).toBe('865546647764037632')
expect(params.get('id')).toBe('exhibit-1')
expect(params.get('stopId')).toBe('865546647764037632')
})
})