11/* eslint-env es6, mocha */
22/* eslint-parser babel-eslint */
33
4+ const packageVersion = require ( '../../package.json' ) . version ;
5+ const sdkVersion = 'mParticle_wsdkv_1.2.3' ;
6+ const kitVersion = 'kitv_' + packageVersion ;
7+
48const waitForCondition = async ( conditionFn , timeout = 200 , interval = 10 ) => {
59 return new Promise ( ( resolve , reject ) => {
610 const startTime = Date . now ( ) ;
@@ -195,10 +199,7 @@ describe('Rokt Forwarder', () => {
195199 null
196200 ) ;
197201
198- var expectedIntegrationName =
199- 'mParticle_wsdkv_1.2.3_kitv_' +
200- require ( '../../package.json' ) . version +
201- '_customName' ;
202+ const expectedIntegrationName = `${ sdkVersion } _${ kitVersion } _customName` ;
202203
203204 window . Rokt . createLauncherCalled . should . equal ( true ) ;
204205 window . Rokt . accountId . should . equal ( '123456' ) ;
@@ -241,7 +242,6 @@ describe('Rokt Forwarder', () => {
241242 } ) ;
242243
243244 it ( 'should set integrationName in the correct format' , async ( ) => {
244- const packageVersion = require ( '../../package.json' ) . version ;
245245 window . Rokt = new MockRoktForwarder ( ) ;
246246 window . mParticle . Rokt = window . Rokt ;
247247 window . mParticle . Rokt . attachKitCalled = false ;
@@ -259,13 +259,12 @@ describe('Rokt Forwarder', () => {
259259 ) ;
260260
261261 window . Rokt . integrationName . should . equal (
262- 'mParticle_wsdkv_1.2.3_kitv_' + packageVersion
262+ ` ${ sdkVersion } _ ${ kitVersion } `
263263 ) ;
264264 } ) ;
265265
266- it ( 'should append custom integration name to integrationName if passed in launcherOptions' , async ( ) => {
267- const packageVersion = require ( '../../package.json' ) . version ;
268- const customIntegrationName = 'myCustomIntegration' ;
266+ it ( 'should not mutate the global launcherOptions object during initialization' , async ( ) => {
267+ const originalIntegrationName = 'globalIntegrationName' ;
269268
270269 window . Rokt = new MockRoktForwarder ( ) ;
271270 window . mParticle . Rokt = window . Rokt ;
@@ -274,16 +273,16 @@ describe('Rokt Forwarder', () => {
274273 window . mParticle . Rokt . attachKitCalled = true ;
275274 return Promise . resolve ( ) ;
276275 } ;
276+
277+ // Set up the global launcherOptions with a custom integration name
277278 window . mParticle . Rokt . launcherOptions = {
278- integrationName : customIntegrationName ,
279+ integrationName : originalIntegrationName ,
280+ sandbox : true ,
279281 } ;
280282
281- // Simulate the forwarder appending the custom integration name
282- window . Rokt . integrationName =
283- 'mParticle_wsdkv_1.2.3_kitv_' +
284- packageVersion +
285- '_' +
286- customIntegrationName ;
283+ // Store reference to verify it doesn't get mutated
284+ const originalLauncherOptions =
285+ window . mParticle . Rokt . launcherOptions ;
287286
288287 await mParticle . forwarder . init (
289288 {
@@ -298,12 +297,14 @@ describe('Rokt Forwarder', () => {
298297 null
299298 ) ;
300299
301- window . Rokt . integrationName . should . equal (
302- 'mParticle_wsdkv_1.2.3_kitv_' +
303- packageVersion +
304- '_' +
305- customIntegrationName
300+ originalLauncherOptions . integrationName . should . equal (
301+ 'globalIntegrationName'
306302 ) ;
303+ originalLauncherOptions . sandbox . should . equal ( true ) ;
304+
305+ // Verify the kit still gets the processed integration name
306+ const expectedProcessedName = `${ sdkVersion } _${ kitVersion } _${ originalIntegrationName } ` ;
307+ window . Rokt . integrationName . should . equal ( expectedProcessedName ) ;
307308 } ) ;
308309 } ) ;
309310
0 commit comments