import axios from 'axios'; import { HostexApiClient } from '../client/index.js'; jest.mock('axios'); const mockedAxios = axios as jest.Mocked; function makeClient() { const mockInstance = { request: jest.fn(), post: jest.fn(), interceptors: { request: { use: jest.fn() }, response: { use: jest.fn() } }, }; mockedAxios.create.mockReturnValue(mockInstance as any); return { client: new HostexApiClient({ accessToken: 'test-token' }), mockInstance }; } describe('HostexApiClient.getRoomTypes query passthrough', () => { it('forwards id and tag_id filters alongside pagination defaults', async () => { const { client, mockInstance } = makeClient(); mockInstance.request.mockResolvedValue({ data: { error_code: 200, data: { room_types: [], total: 0 } }, }); await client.getRoomTypes({ id: 9, tag_id: 2 }); expect(mockInstance.request).toHaveBeenCalledWith({ method: 'GET', url: '/room_types', params: { id: 9, tag_id: 2, offset: 0, limit: 20 }, }); }); }); describe('HostexApiClient.createReview category_ratings passthrough', () => { it('includes category_ratings in the POST body', async () => { const { client, mockInstance } = makeClient(); mockInstance.post.mockResolvedValue({ data: { error_code: 200 }, }); await client.createReview({ reservation_code: 'R1', host_review_score: 5, category_ratings: { overall_rating: 5 }, }); expect(mockInstance.post).toHaveBeenCalledWith('/reviews/R1', { host_review_score: 5, host_review_content: undefined, host_reply_content: undefined, category_ratings: { overall_rating: 5 }, }); }); });