2023-04-10 22:53:15 +08:00
|
|
|
import { describe, test, expect } from 'vitest';
|
2023-04-18 19:50:40 +08:00
|
|
|
import {
|
|
|
|
requestMethodNames,
|
|
|
|
requestMethodWithDataNames,
|
|
|
|
requestMethodWithParamsNames,
|
|
|
|
} from '@/core/AxiosDomain';
|
2023-04-09 15:20:10 +08:00
|
|
|
import axios from '@/axios';
|
2023-04-10 22:53:15 +08:00
|
|
|
import defaults from '@/defaults';
|
2023-04-09 15:20:10 +08:00
|
|
|
|
|
|
|
describe('src/axios.ts', () => {
|
|
|
|
test('应该有这些实例属性及方法', () => {
|
|
|
|
expect(axios.defaults).toBe(defaults);
|
|
|
|
expect(axios.interceptors).toBeTypeOf('object');
|
|
|
|
expect(axios.getUri).toBeTypeOf('function');
|
|
|
|
expect(axios.fork).toBeTypeOf('function');
|
|
|
|
expect(axios.request).toBeTypeOf('function');
|
|
|
|
|
2023-04-18 19:50:40 +08:00
|
|
|
[
|
|
|
|
...requestMethodNames,
|
|
|
|
...requestMethodWithParamsNames,
|
|
|
|
...requestMethodWithDataNames,
|
|
|
|
].forEach((k) => {
|
2023-04-09 15:20:10 +08:00
|
|
|
expect(axios[k]).toBeTypeOf('function');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|