mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
28 lines
870 B
TypeScript
28 lines
870 B
TypeScript
import { Axios } from 'axios';
|
|
import { isStorage } from '../../src/storage/build';
|
|
import { buildMemoryStorage } from '../../src/storage/memory';
|
|
import type { AxiosStorage } from '../../src/storage/types';
|
|
import { mockAxios } from '../mocks/axios';
|
|
|
|
it('tests isStorage function', () => {
|
|
expect(isStorage(void 0)).toBe(false);
|
|
expect(isStorage(1)).toBe(false);
|
|
expect(isStorage('a')).toBe(false);
|
|
expect(isStorage({})).toBe(false);
|
|
expect(isStorage(Axios)).toBe(false);
|
|
expect(isStorage(() => 0)).toBe(false);
|
|
expect(isStorage(null)).toBe(false);
|
|
expect(isStorage(undefined)).toBe(false);
|
|
expect(isStorage({ a: 1, b: 'a' })).toBe(false);
|
|
|
|
expect(isStorage(buildMemoryStorage())).toBe(true);
|
|
});
|
|
|
|
it('tests setupCache without proper storage', () => {
|
|
expect(() =>
|
|
mockAxios({
|
|
storage: {} as AxiosStorage
|
|
})
|
|
).toThrowError();
|
|
});
|