|
2 | 2 | // @ts-nocheck |
3 | 3 | import Point from '@mapbox/point-geometry'; |
4 | 4 | import {describe, test, expect} from '../../util/vitest'; |
5 | | -import {mapValue, degToRad, radToDeg, easeCubicInOut, getAABBPointSquareDist, furthestTileCorner, keysDifference, pick, uniqueId, bindAll, asyncAll, clamp, smoothstep, wrap, bezier, mapObject, filterObject, deepEqual, clone, arraysIntersect, isCounterClockwise, parseCacheControl, uuid, validateUuid, nextPowerOfTwo, isPowerOfTwo, bufferConvexPolygon, prevPowerOfTwo, shortestAngle, _resetSafariCheckForTest, isSafariWithAntialiasingBug} from '../../../src/util/util'; |
| 5 | +import {mapValue, degToRad, radToDeg, easeCubicInOut, getAABBPointSquareDist, furthestTileCorner, keysDifference, pick, uniqueId, bindAll, asyncAll, clamp, smoothstep, wrap, bezier, mapObject, filterObject, deepEqual, clone, arraysIntersect, isCounterClockwise, parseCacheControl, getExpiryDataFromHeaders, uuid, validateUuid, nextPowerOfTwo, isPowerOfTwo, bufferConvexPolygon, prevPowerOfTwo, shortestAngle, _resetSafariCheckForTest, isSafariWithAntialiasingBug} from '../../../src/util/util'; |
6 | 6 |
|
7 | 7 | const EPSILON = 1e-8; |
8 | 8 |
|
@@ -368,6 +368,35 @@ describe('util', () => { |
368 | 368 | }); |
369 | 369 | }); |
370 | 370 |
|
| 371 | + describe('getExpiryDataFromHeaders', () => { |
| 372 | + test('returns undefined values when responseHeaders is undefined', () => { |
| 373 | + expect(getExpiryDataFromHeaders(undefined)).toEqual({ |
| 374 | + cacheControl: undefined, |
| 375 | + expires: undefined |
| 376 | + }); |
| 377 | + }); |
| 378 | + |
| 379 | + test('reads cache headers from a Fetch API Headers object', () => { |
| 380 | + const headers = new Headers(); |
| 381 | + headers.set('Cache-Control', 'max-age=60'); |
| 382 | + headers.set('Expires', 'Thu, 01 Jan 2099 00:00:00 GMT'); |
| 383 | + |
| 384 | + const result = getExpiryDataFromHeaders(headers); |
| 385 | + expect(result.cacheControl).toBe('max-age=60'); |
| 386 | + expect(result.expires).toBe('Thu, 01 Jan 2099 00:00:00 GMT'); |
| 387 | + }); |
| 388 | + |
| 389 | + test('reads cache headers from a Map serialized via Headers.entries()', () => { |
| 390 | + const headers = new Headers(); |
| 391 | + headers.set('Cache-Control', 'max-age=30'); |
| 392 | + headers.set('Expires', 'Thu, 01 Jan 2099 00:00:00 GMT'); |
| 393 | + |
| 394 | + const result = getExpiryDataFromHeaders(new Map(headers.entries())); |
| 395 | + expect(result.cacheControl).toBe('max-age=30'); |
| 396 | + expect(result.expires).toBe('Thu, 01 Jan 2099 00:00:00 GMT'); |
| 397 | + }); |
| 398 | + }); |
| 399 | + |
371 | 400 | test('validateUuid', () => { |
372 | 401 | expect(validateUuid(uuid())).toBeTruthy(); |
373 | 402 | expect(validateUuid(uuid().substr(0, 10))).toBeFalsy(); |
|
0 commit comments