2021-09-19 19:29:05 -03:00

30 lines
794 B
TypeScript

import { mockAxios } from '../mocks/axios';
describe('test request interceptor', () => {
it('tests against specified methods', async () => {
const axios = mockAxios({
// only cache post methods
methods: ['post']
});
const response = await axios.get('');
const cacheKey = await axios.generateKey(response.config);
const cache = await axios.storage.get(cacheKey);
expect(cache.state).toBe('empty');
});
it('tests specified methods', async () => {
const axios = mockAxios({
// only cache get methods
methods: ['get']
});
const response = await axios.get('');
const cacheKey = await axios.generateKey(response.config);
const cache = await axios.storage.get(cacheKey);
expect(cache.state).toBe('cached');
});
});