@@ -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' , ( ) => {
@@ -1212,6 +1216,10 @@ describe("mapbox", () => {
12121216 expect ( mapLoadEvent . version ) . toEqual ( '2.2' ) ;
12131217 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
12141218 expect ( mapLoadEvent . sdkInfo ) . toBeUndefined ( ) ;
1219+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1220+ expect ( mapLoadEvent . bundleFormat ) . toEqual ( 'unknown' ) ;
1221+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1222+ expect ( mapLoadEvent . bundleDistribution ) . toEqual ( 'other' ) ;
12151223 } ) ;
12161224
12171225 test ( 'setSdkInfo ignores invalid values' , async ( ) => {
@@ -1667,4 +1675,32 @@ describe("mapbox", () => {
16671675 expect ( mapbox . parseAccessToken ( 'a.!!!.c' ) ) . toBeNull ( ) ;
16681676 } ) ;
16691677 } ) ;
1678+
1679+ describe ( 'setBundleDistribution' , ( ) => {
1680+ let event : any ;
1681+ const skuToken = '1234567890123' ;
1682+ beforeEach ( ( ) => {
1683+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1684+ window . useFakeXMLHttpRequest ( ) ;
1685+ event = new mapbox . MapLoadEvent ( ) ;
1686+ } ) ;
1687+ afterEach ( ( ) => {
1688+ // Reset the module-level state set by these tests (default is 'other').
1689+ mapbox . setBundleDistribution ( 'other' ) ;
1690+ } ) ;
1691+
1692+ async function getBundleDistribution ( ) : Promise < string > {
1693+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
1694+ const reqBody = await window . server . requests [ 0 ] . requestBody ;
1695+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1696+ return JSON . parse ( reqBody . slice ( 1 , reqBody . length - 1 ) ) . bundleDistribution ;
1697+ }
1698+
1699+ test ( 'payload reflects the bundleDistribution set via setBundleDistribution' , async ( ) => {
1700+ mapbox . setBundleDistribution ( 'cdn' ) ;
1701+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
1702+ event . postMapLoadEvent ( 1 , skuToken ) ;
1703+ expect ( await getBundleDistribution ( ) ) . toEqual ( 'cdn' ) ;
1704+ } ) ;
1705+ } ) ;
16701706} ) ;
0 commit comments