diff --git a/src/cache/create.ts b/src/cache/create.ts index 24638170..a84c234b 100644 --- a/src/cache/create.ts +++ b/src/cache/create.ts @@ -10,8 +10,6 @@ import type { CacheInstance, CacheProperties } from './cache'; export type CacheOptions = Partial & Partial; -const symbolKey = Symbol(); - /** * Apply the caching interceptors for a already created axios instance. * @@ -92,11 +90,8 @@ export function setupCache( }; // Apply interceptors - axiosCache.requestInterceptor.apply(axiosCache); - axiosCache.responseInterceptor.apply(axiosCache); - - // @ts-expect-error - internal only - axiosCache[symbolKey] = 1; + axiosCache.requestInterceptor.apply(); + axiosCache.responseInterceptor.apply(); return axiosCache; } @@ -105,13 +100,3 @@ export function setupCache( export const useCache = setupCache as unknown as 'use setupCache instead'; /** @deprecated */ export const createCache = setupCache as unknown as 'use setupCache instead'; - -/** - * Detects if the given parameter has caching enabled. The only way to this return true is - * by using the {@link setupCache} function. - * - * @param axios The axios instance to use - * @returns True if the axios instance is using the caching interceptor - */ -export const isAxiosCacheInterceptor = (axios: any): axios is AxiosCacheInstance => - !!axios && !!axios[symbolKey]; diff --git a/test/bundle.test.ts b/test/bundle.test.ts index 24d6f1b9..9b5cc117 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -1,4 +1,4 @@ -import { isAxiosCacheInterceptor, setupCache } from '../src/cache/create'; +import { setupCache } from '../src/cache/create'; import { buildMemoryStorage } from '../src/storage/memory'; import { buildWebStorage } from '../src/storage/web-api'; @@ -12,7 +12,6 @@ describe('test bundle imports', () => { expect(console.warn).toHaveBeenCalledTimes(1); expect(bundle.setupCache).toBe(setupCache); - expect(bundle.isAxiosCacheInterceptor).toBe(isAxiosCacheInterceptor); expect(bundle.buildMemoryStorage).toBe(buildMemoryStorage); expect(bundle.buildWebStorage).toBe(buildWebStorage); diff --git a/test/cache/create.test.ts b/test/cache/create.test.ts index 00dc98a9..3fd3f361 100644 --- a/test/cache/create.test.ts +++ b/test/cache/create.test.ts @@ -1,5 +1,5 @@ import Axios from 'axios'; -import { isAxiosCacheInterceptor, setupCache } from '../../src/cache/create'; +import { setupCache } from '../../src/cache/create'; describe('tests header interpreter', () => { it('tests argument composition', () => { @@ -11,18 +11,4 @@ describe('tests header interpreter', () => { expect(withConfig).not.toBeUndefined(); expect(withConfig.defaults.cache.ttl).toBe(1234); }); - - it('tests isAxiosCacheInterceptor', () => { - expect(isAxiosCacheInterceptor(void 0)).toBe(false); - expect(isAxiosCacheInterceptor(1)).toBe(false); - expect(isAxiosCacheInterceptor('a')).toBe(false); - expect(isAxiosCacheInterceptor({})).toBe(false); - expect(isAxiosCacheInterceptor(Axios)).toBe(false); - expect(isAxiosCacheInterceptor(() => 0)).toBe(false); - expect(isAxiosCacheInterceptor(null)).toBe(false); - expect(isAxiosCacheInterceptor(undefined)).toBe(false); - expect(isAxiosCacheInterceptor({ a: 1, b: 'a' })).toBe(false); - - expect(isAxiosCacheInterceptor(setupCache(Axios.create()))).toBe(true); - }); });