Download next.js/test/unit/image-optimizer/get-max-age.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/image-optimizer/get-max-age.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/unit/image-optimizer/get-max-age.test.ts
-
curl -L -o get-max-age.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/unit/image-optimizer/get-max-age.test.ts
1.55 kB
| /* eslint-env jest */ | |
| import { getMaxAge } from 'next/dist/server/image-optimizer' | |
| describe('getMaxAge', () => { | |
| it('should return 0 when no cache-control provided', () => { | |
| expect(getMaxAge(undefined)).toBe(0) | |
| }) | |
| it('should return 0 when cache-control is null', () => { | |
| expect(getMaxAge(null)).toBe(0) | |
| }) | |
| it('should return 0 when cache-control is empty string', () => { | |
| expect(getMaxAge('')).toBe(0) | |
| }) | |
| it('should return 0 when cache-control max-age is not a number', () => { | |
| expect(getMaxAge('max-age=foo')).toBe(0) | |
| }) | |
| it('should return 0 when cache-control is no-cache', () => { | |
| expect(getMaxAge('no-cache')).toBe(0) | |
| }) | |
| it('should return cache-control max-age lowercase', () => { | |
| expect(getMaxAge('max-age=9999')).toBe(9999) | |
| }) | |
| it('should return cache-control MAX-AGE uppercase', () => { | |
| expect(getMaxAge('MAX-AGE=9999')).toBe(9999) | |
| }) | |
| it('should return cache-control s-maxage lowercase', () => { | |
| expect(getMaxAge('s-maxage=9999')).toBe(9999) | |
| }) | |
| it('should return cache-control S-MAXAGE', () => { | |
| expect(getMaxAge('S-MAXAGE=9999')).toBe(9999) | |
| }) | |
| it('should return cache-control s-maxage with spaces', () => { | |
| expect(getMaxAge('public, max-age=5555, s-maxage=9999')).toBe(9999) | |
| }) | |
| it('should return cache-control s-maxage without spaces', () => { | |
| expect(getMaxAge('public,s-maxage=9999,max-age=5555')).toBe(9999) | |
| }) | |
| it('should return cache-control for a quoted value', () => { | |
| expect(getMaxAge('public, s-maxage="9999", max-age="5555"')).toBe(9999) | |
| }) | |
| }) | |