mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
2f52f6b13b
* feat: added smoke tests for deno * feat: added bun smoke tests * chore: added workflows for deno and bun * chore: swap workflow implementation * chore: apply ai suggestion * chore: test alt install of bun deps * chore: deno install * chore: map bun file install * chore: try a different approach for bun * chore: unpack and then install for bun * chore: remove un-needed step * chore: try with tgx again for bun * chore: alternative zip approach * ci: full ci added back
34 lines
888 B
TypeScript
34 lines
888 B
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import axios from 'axios';
|
|
|
|
const env = (fetch: typeof globalThis.fetch) => ({
|
|
fetch,
|
|
Request,
|
|
Response,
|
|
});
|
|
|
|
describe('errors', () => {
|
|
test('non-2xx response rejects with AxiosError and status 404', async () => {
|
|
const fetch = async () =>
|
|
new Response(JSON.stringify({ error: 'missing' }), {
|
|
status: 404,
|
|
statusText: 'Not Found',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
|
|
const err = await axios
|
|
.get('https://example.com/missing', {
|
|
adapter: 'fetch',
|
|
env: env(fetch),
|
|
})
|
|
.catch((e: any) => e);
|
|
|
|
expect(axios.isAxiosError(err)).toBe(true);
|
|
expect(err.response.status).toBe(404);
|
|
});
|
|
|
|
test('axios.isAxiosError returns false for a plain Error', () => {
|
|
expect(axios.isAxiosError(new Error('plain'))).toBe(false);
|
|
});
|
|
});
|