diff --git a/packages/libs/core-api/src/axiosHelpers.js b/packages/libs/core-api/src/axiosHelpers.js index 7b85220..7483bfd 100644 --- a/packages/libs/core-api/src/axiosHelpers.js +++ b/packages/libs/core-api/src/axiosHelpers.js @@ -1,6 +1,6 @@ import axios from 'axios'; import axiosRetry from 'axios-retry'; -import { setupCache } from 'axios-cache-adapter'; +// import { setupCache } from 'axios-cache-adapter'; import backoff from './utils/backoff'; // Exported only for unit test coverage @@ -10,12 +10,12 @@ export const customCacheInvalidate = async (config, request) => { } }; -const cache = setupCache({ - // 15 minute cache - maxAge: 15 * 60 * 1000, - // Invalidate only when a specific option is passed through config - invalidate: customCacheInvalidate, -}); +// const cache = setupCache({ +// // 15 minute cache +// maxAge: 15 * 60 * 1000, +// // Invalidate only when a specific option is passed through config +// invalidate: customCacheInvalidate, +// }); export const getHeaderWithoutAuth = (optionalHeaders = {}) => { return { @@ -46,7 +46,7 @@ export const createAxiosCancelable = ({ const canceler = axios.CancelToken.source(); const auth = getHeaderWithoutAuth(); if (withCache) { - auth.adapter = cache.adapter; + // auth.adapter = cache.adapter; } const client = axios.create(auth); axiosRetry(client, backoff(min, max)); diff --git a/packages/libs/core-api/src/axiosHelpers.test.js b/packages/libs/core-api/src/axiosHelpers.test.js index 15fc3d8..559f554 100644 --- a/packages/libs/core-api/src/axiosHelpers.test.js +++ b/packages/libs/core-api/src/axiosHelpers.test.js @@ -119,58 +119,58 @@ describe('axiosHelpers', () => { expect(backoff).toHaveBeenCalledWith(expectedMin, expectedMax); }); - describe('cache', () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it('when withCache is true, axios create is called with adapter', () => { - createAxiosCancelable({ withCache: true }); - - expect(axios.create).toBeCalledWith( - expect.objectContaining({ - adapter: expect.any(Function), - }), - ); - }); - - it('when withCache is false, axios create is called without adapter', () => { - createAxiosCancelable({ withCache: false }); - - expect(axios.create).not.toBeCalledWith( - expect.objectContaining({ - adapter: expect.any(Function), - }), - ); - }); - - it('when withCache not specified, axios create is called without adapter', () => { - createAxiosCancelable(); - - expect(axios.create).not.toBeCalledWith( - expect.objectContaining({ - adapter: expect.any(Function), - }), - ); - }); - - it('when invalidate function on cache is called, it looks for clearCacheEntry in the request before invalidating the cache', async () => { - const mockRemoveItem = jest.fn(); - const mockUuid = 'mockUuid'; - const mockConfig = { - store: { - removeItem: mockRemoveItem, - }, - uuid: mockUuid, - }; - - customCacheInvalidate(mockConfig, {}); - expect(mockRemoveItem).not.toHaveBeenCalled(); - const mockRequest = { clearCacheEntry: true }; - - customCacheInvalidate(mockConfig, mockRequest); - expect(mockRemoveItem).toHaveBeenCalledWith(mockUuid); - }); - }); + // describe('cache', () => { + // beforeEach(() => { + // jest.clearAllMocks(); + // }); + + // it('when withCache is true, axios create is called with adapter', () => { + // createAxiosCancelable({ withCache: true }); + + // expect(axios.create).toBeCalledWith( + // expect.objectContaining({ + // adapter: expect.any(Function), + // }), + // ); + // }); + + // it('when withCache is false, axios create is called without adapter', () => { + // createAxiosCancelable({ withCache: false }); + + // expect(axios.create).not.toBeCalledWith( + // expect.objectContaining({ + // adapter: expect.any(Function), + // }), + // ); + // }); + + // it('when withCache not specified, axios create is called without adapter', () => { + // createAxiosCancelable(); + + // expect(axios.create).not.toBeCalledWith( + // expect.objectContaining({ + // adapter: expect.any(Function), + // }), + // ); + // }); + + // it('when invalidate function on cache is called, it looks for clearCacheEntry in the request before invalidating the cache', async () => { + // const mockRemoveItem = jest.fn(); + // const mockUuid = 'mockUuid'; + // const mockConfig = { + // store: { + // removeItem: mockRemoveItem, + // }, + // uuid: mockUuid, + // }; + + // customCacheInvalidate(mockConfig, {}); + // expect(mockRemoveItem).not.toHaveBeenCalled(); + // const mockRequest = { clearCacheEntry: true }; + + // customCacheInvalidate(mockConfig, mockRequest); + // expect(mockRemoveItem).toHaveBeenCalledWith(mockUuid); + // }); + // }); }); });