@@ -783,6 +783,10 @@ describe("mapbox", () => {
783783 expect ( ! ! mapLoadEvent . userId ) . toBeTruthy ( ) ;
784784 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
785785 expect ( ! ! mapLoadEvent . created ) . toBeTruthy ( ) ;
786+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
787+ expect ( mapLoadEvent . bundleFormat ) . toEqual ( 'unknown' ) ;
788+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
789+ expect ( mapLoadEvent . bundleDistribution ) . toEqual ( 'other' ) ;
786790 } ) ;
787791
788792 test ( 'does not POST when mapboxgl.ACCESS_TOKEN is not set' , ( ) => {
@@ -1211,6 +1215,10 @@ describe("mapbox", () => {
12111215 expect ( mapLoadEvent . version ) . toEqual ( '2.2' ) ;
12121216 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
12131217 expect ( mapLoadEvent . sdkInfo ) . toBeUndefined ( ) ;
1218+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1219+ expect ( mapLoadEvent . bundleFormat ) . toEqual ( 'unknown' ) ;
1220+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1221+ expect ( mapLoadEvent . bundleDistribution ) . toEqual ( 'other' ) ;
12141222 } ) ;
12151223
12161224 test ( 'setSdkInfo ignores invalid values' , async ( ) => {
@@ -1661,4 +1669,32 @@ describe("mapbox", () => {
16611669 expect ( mapbox . parseAccessToken ( 'a.!!!.c' ) ) . toBeNull ( ) ;
16621670 } ) ;
16631671 } ) ;
1672+
1673+ describe ( 'setBundleDistribution' , ( ) => {
1674+ let event : any ;
1675+ const skuToken = '1234567890123' ;
1676+ beforeEach ( ( ) => {
1677+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1678+ window . useFakeXMLHttpRequest ( ) ;
1679+ event = new mapbox . MapLoadEvent ( ) ;
1680+ } ) ;
1681+ afterEach ( ( ) => {
1682+ // Reset the module-level state set by these tests (default is 'other').
1683+ mapbox . setBundleDistribution ( 'other' ) ;
1684+ } ) ;
1685+
1686+ async function getBundleDistribution ( ) : Promise < string > {
1687+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
1688+ const reqBody = await window . server . requests [ 0 ] . requestBody ;
1689+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1690+ return JSON . parse ( reqBody . slice ( 1 , reqBody . length - 1 ) ) . bundleDistribution ;
1691+ }
1692+
1693+ test ( 'payload reflects the bundleDistribution set via setBundleDistribution' , async ( ) => {
1694+ mapbox . setBundleDistribution ( 'cdn' ) ;
1695+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1696+ event . postMapLoadEvent ( 1 , skuToken ) ;
1697+ expect ( await getBundleDistribution ( ) ) . toEqual ( 'cdn' ) ;
1698+ } ) ;
1699+ } ) ;
16641700} ) ;
0 commit comments