mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2025-12-08 17:36:16 +00:00
34 lines
883 B
TypeScript
34 lines
883 B
TypeScript
import { Header } from '../../src/header/headers';
|
|
import { defaultHeaderInterpreter } from '../../src/header/interpreter';
|
|
|
|
describe('test Cache-Control header', () => {
|
|
it('tests with cache preventing headers', () => {
|
|
const noStore = defaultHeaderInterpreter({
|
|
[Header.CacheControl]: 'no-store'
|
|
});
|
|
|
|
expect(noStore).toBe('dont cache');
|
|
|
|
const noCache = defaultHeaderInterpreter({
|
|
[Header.CacheControl]: 'no-cache'
|
|
});
|
|
|
|
expect(noCache).toBe('dont cache');
|
|
|
|
const mustRevalidate = defaultHeaderInterpreter({
|
|
[Header.CacheControl]: 'must-revalidate'
|
|
});
|
|
|
|
expect(mustRevalidate).toBe(0);
|
|
});
|
|
|
|
it('tests with maxAge header for 10 seconds', () => {
|
|
const result = defaultHeaderInterpreter({
|
|
[Header.CacheControl]: 'max-age=10'
|
|
});
|
|
|
|
// 10 Seconds in milliseconds
|
|
expect(result).toBe(10 * 1000);
|
|
});
|
|
});
|