@@ -4,7 +4,6 @@ import {describe, test, beforeEach, afterEach, expect, vi, equalWithPrecision} f
44import { getRequestBody } from '../../util/network' ;
55import * as mapbox from '../../../src/util/mapbox' ;
66import config from '../../../src/util/config' ;
7- import webpSupported from '../../../src/util/webp_supported' ;
87import { uuid } from '../../../src/util/util' ;
98import { SKU_ID } from '../../../src/util/sku_token' ;
109import { version } from '../../../package.json' ;
@@ -131,8 +130,6 @@ describe("mapbox", () => {
131130 } ) ;
132131 } ) ;
133132
134- webpSupported . supported = false ;
135-
136133 describe ( '.normalizeStyleURL' , ( ) => {
137134 test (
138135 'returns an API URL with access_token parameter when no query string' ,
@@ -421,44 +418,33 @@ describe("mapbox", () => {
421418 } ) ;
422419
423420 describe ( '.normalizeTileURL' , ( ) => {
424- test ( '.normalizeTileURL does nothing on 1x devices' , ( ) => {
425- config . API_URL = 'http://path.png' ;
426- config . REQUIRE_ACCESS_TOKEN = false ;
427- webpSupported . supported = false ;
428- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' ) ) . toEqual ( `http://path.png/v4/tile.png` ) ;
429- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png32' ) ) . toEqual ( `http://path.png/v4/tile.png32` ) ;
430- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.jpg70' ) ) . toEqual ( `http://path.png/v4/tile.jpg70` ) ;
431- } ) ;
432-
433421 test ( '.normalizeTileURL inserts @2x if source requests it' , ( ) => {
434422 config . API_URL = 'http://path.png' ;
435423 config . REQUIRE_ACCESS_TOKEN = false ;
436- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.png ` ) ;
437- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png32' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.png32 ` ) ;
438- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.jpg70' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.jpg70 ` ) ;
424+ expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.webp ` ) ;
425+ expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png32' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.webp ` ) ;
426+ expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.jpg70' , true ) ) . toEqual ( `http://path.png/v4/tile@2x.webp ` ) ;
439427 expect (
440428 manager . normalizeTileURL ( 'mapbox://path.png/tile.png?access_token=foo' , true )
441- ) . toEqual ( `http://path.png/v4/tile@2x.png ?access_token=foo` ) ;
429+ ) . toEqual ( `http://path.png/v4/tile@2x.webp ?access_token=foo` ) ;
442430 } ) ;
443431
444432 test ( '.normalizeTileURL inserts @2x for 512 raster tiles on v4 of the api' , ( ) => {
445433 config . API_URL = 'http://path.png' ;
446434 config . REQUIRE_ACCESS_TOKEN = false ;
447- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , false , 256 ) ) . toEqual ( `http://path.png/v4/tile.png ` ) ;
448- expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , false , 512 ) ) . toEqual ( `http://path.png/v4/tile@2x.png ` ) ;
449- expect ( manager . normalizeTileURL ( "mapbox://raster/a.b/0/0/0.png" , false , 256 ) ) . toEqual ( `http://path.png/raster/v1/a.b/0/0/0.png ` ) ;
450- expect ( manager . normalizeTileURL ( "mapbox://raster/a.b/0/0/0.png" , false , 512 ) ) . toEqual ( `http://path.png/raster/v1/a.b/0/0/0.png ` ) ;
435+ expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , false , 256 ) ) . toEqual ( `http://path.png/v4/tile.webp ` ) ;
436+ expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' , false , 512 ) ) . toEqual ( `http://path.png/v4/tile@2x.webp ` ) ;
437+ expect ( manager . normalizeTileURL ( "mapbox://raster/a.b/0/0/0.png" , false , 256 ) ) . toEqual ( `http://path.png/raster/v1/a.b/0/0/0.webp ` ) ;
438+ expect ( manager . normalizeTileURL ( "mapbox://raster/a.b/0/0/0.png" , false , 512 ) ) . toEqual ( `http://path.png/raster/v1/a.b/0/0/0.webp ` ) ;
451439 } ) ;
452440
453- test ( '.normalizeTileURL replaces img extension with webp on supporting devices' , ( ) => {
454- webpSupported . supported = true ;
441+ test ( '.normalizeTileURL replaces img extension with webp' , ( ) => {
455442 config . API_URL = 'http://path.png' ;
456443 config . REQUIRE_ACCESS_TOKEN = false ;
457444 expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png' ) ) . toEqual ( `http://path.png/v4/tile.webp` ) ;
458445 expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png32' ) ) . toEqual ( `http://path.png/v4/tile.webp` ) ;
459446 expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.jpg70' ) ) . toEqual ( `http://path.png/v4/tile.webp` ) ;
460447 expect ( manager . normalizeTileURL ( 'mapbox://path.png/tile.png?access_token=foo' ) ) . toEqual ( `http://path.png/v4/tile.webp?access_token=foo` ) ;
461- webpSupported . supported = false ;
462448 } ) ;
463449
464450 test ( '.normalizeTileURL ignores non-mapbox:// sources' , ( ) => {
@@ -506,16 +492,16 @@ describe("mapbox", () => {
506492 `https://api.mapbox.com/v4/a.b/0/0/0.pbf?sku=${ manager . _skuToken } &access_token=key`
507493 ) ;
508494 expect ( manager . normalizeTileURL ( "mapbox://tiles/a.b/0/0/0.png" ) ) . toEqual (
509- `https://api.mapbox.com/v4/a.b/0/0/0.png ?sku=${ manager . _skuToken } &access_token=key`
495+ `https://api.mapbox.com/v4/a.b/0/0/0.webp ?sku=${ manager . _skuToken } &access_token=key`
510496 ) ;
511497 expect ( manager . normalizeTileURL ( "mapbox://tiles/a.b/0/0/0@2x.png" ) ) . toEqual (
512- `https://api.mapbox.com/v4/a.b/0/0/0@2x.png ?sku=${ manager . _skuToken } &access_token=key`
498+ `https://api.mapbox.com/v4/a.b/0/0/0@2x.webp ?sku=${ manager . _skuToken } &access_token=key`
513499 ) ;
514500 expect ( manager . normalizeTileURL ( "mapbox://tiles/a.b,c.d/0/0/0.pbf" ) ) . toEqual (
515501 `https://api.mapbox.com/v4/a.b,c.d/0/0/0.pbf?sku=${ manager . _skuToken } &access_token=key`
516502 ) ;
517503 expect ( manager . normalizeTileURL ( "mapbox://raster/a.b/0/0/0.png" ) ) . toEqual (
518- `https://api.mapbox.com/raster/v1/a.b/0/0/0.png ?sku=${ manager . _skuToken } &access_token=key`
504+ `https://api.mapbox.com/raster/v1/a.b/0/0/0.webp ?sku=${ manager . _skuToken } &access_token=key`
519505 ) ;
520506 expect ( manager . normalizeTileURL ( "mapbox://rasterarrays/a.b/0/0/0.mrt" ) ) . toEqual (
521507 `https://api.mapbox.com/rasterarrays/v1/a.b/0/0/0.mrt?sku=${ manager . _skuToken } &access_token=key`
@@ -526,13 +512,11 @@ describe("mapbox", () => {
526512
527513 config . API_URL = 'https://api.example.com/' ;
528514 expect ( manager . normalizeTileURL ( "mapbox://tiles/a.b/0/0/0.png" ) ) . toEqual (
529- `https://api.example.com/v4/a.b/0/0/0.png ?sku=${ manager . _skuToken } &access_token=key`
515+ `https://api.example.com/v4/a.b/0/0/0.webp ?sku=${ manager . _skuToken } &access_token=key`
530516 ) ;
531517 expect ( manager . normalizeTileURL ( "http://path" ) ) . toEqual ( "http://path" ) ;
532518 } ) ;
533519 } ) ;
534-
535- webpSupported . supported = true ;
536520 } ) ;
537521
538522 describe ( 'TelemetryEvent' , ( ) => {
0 commit comments