|
|
@@ -18,7 +18,9 @@ import { mockCameras, mockChannels, wrapResponse } from '../../fixtures'
|
|
|
|
|
|
vi.mock('@/utils/request', () => ({
|
|
|
get: vi.fn(),
|
|
|
- post: vi.fn()
|
|
|
+ post: vi.fn(),
|
|
|
+ ptzGet: vi.fn(),
|
|
|
+ ptzPost: vi.fn()
|
|
|
}))
|
|
|
|
|
|
describe('Camera API', () => {
|
|
|
@@ -48,14 +50,14 @@ describe('Camera API', () => {
|
|
|
})
|
|
|
|
|
|
describe('getCamera', () => {
|
|
|
- it('should call GET /camera/control/:id', async () => {
|
|
|
+ it('should call GET /cameras/:id', async () => {
|
|
|
const camera = mockCameras[0]
|
|
|
const mockResponse = wrapResponse(camera)
|
|
|
vi.mocked(request.get).mockResolvedValue(mockResponse)
|
|
|
|
|
|
const result = await getCamera(camera.cameraId)
|
|
|
|
|
|
- expect(request.get).toHaveBeenCalledWith(`/camera/control/${camera.cameraId}`)
|
|
|
+ expect(request.get).toHaveBeenCalledWith(`/cameras/${camera.cameraId}`)
|
|
|
expect(result.data.cameraId).toBe(camera.cameraId)
|
|
|
})
|
|
|
})
|
|
|
@@ -90,26 +92,31 @@ describe('Camera API', () => {
|
|
|
})
|
|
|
|
|
|
describe('ptzStart', () => {
|
|
|
- it('should call POST /camera/control/:id/ptz/start', async () => {
|
|
|
+ it('should call POST /ptz/control with PTZ service', async () => {
|
|
|
const mockResponse = wrapResponse(null)
|
|
|
- vi.mocked(request.post).mockResolvedValue(mockResponse)
|
|
|
+ vi.mocked(request.ptzPost).mockResolvedValue(mockResponse)
|
|
|
|
|
|
await ptzStart('cam-001', 'up', 50)
|
|
|
|
|
|
- expect(request.post).toHaveBeenCalledWith('/camera/control/cam-001/ptz/start', undefined, {
|
|
|
- params: { action: 'up', speed: 50 }
|
|
|
+ expect(request.ptzPost).toHaveBeenCalledWith('/ptz/control', {
|
|
|
+ host: 'cam-001',
|
|
|
+ command: 'up',
|
|
|
+ speed: 50
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('ptzStop', () => {
|
|
|
- it('should call POST /camera/control/:id/ptz/stop', async () => {
|
|
|
+ it('should call POST /ptz/control with stop command', async () => {
|
|
|
const mockResponse = wrapResponse(null)
|
|
|
- vi.mocked(request.post).mockResolvedValue(mockResponse)
|
|
|
+ vi.mocked(request.ptzPost).mockResolvedValue(mockResponse)
|
|
|
|
|
|
await ptzStop('cam-001')
|
|
|
|
|
|
- expect(request.post).toHaveBeenCalledWith('/camera/control/cam-001/ptz/stop')
|
|
|
+ expect(request.ptzPost).toHaveBeenCalledWith('/ptz/control', {
|
|
|
+ host: 'cam-001',
|
|
|
+ command: 'stop'
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
})
|