const { describe, it, expect } = require('@jest/globals'); const { makeAxiosInstance } = require('../../src/utils/axios-instance'); function createStubAdapter() { let capturedConfig = null; const adapter = (config) => { capturedConfig = config; return Promise.resolve({ data: {}, status: 200, statusText: 'OK', headers: {}, config }); }; adapter.getConfig = () => capturedConfig; return adapter; } describe('makeAxiosInstance', () => { it('setting User-Agent does not clobber the axios default Accept header', async () => { const stubAdapter = createStubAdapter(); const instance = makeAxiosInstance(); await instance({ url: 'https://api.example.com/test', method: 'get', adapter: stubAdapter }); // axios.create() sets Accept by default; assigning a new object to defaults.headers.common // would nuke it. Guard against that regression. expect(stubAdapter.getConfig().headers['Accept']).toMatch(/application\/json/); }); it('sets User-Agent header to bruno-runtime version', async () => { const stubAdapter = createStubAdapter(); const instance = makeAxiosInstance(); await instance({ url: 'https://api.example.com/test', method: 'get', adapter: stubAdapter }); expect(stubAdapter.getConfig().headers['User-Agent']).toMatch(/^bruno-runtime\//); }); });