@@ -201,15 +201,20 @@ describe('Rokt Forwarder', () => {
201201 } ;
202202 window . mParticle . forwarder . launcher = {
203203 hashAttributes : function ( attributes ) {
204- window . mParticle . Rokt . hashAttributesOptions = attributes ;
205- window . mParticle . Rokt . hashAttributesCalled = true ;
206-
207204 // Mocking the hashAttributes method to show that
208205 // the attributes will be transformed by the launcher's
209206 // hashAttributes method.
210- return Promise . resolve ( {
211- 'test-attribute' : 'hashed-value' ,
212- } ) ;
207+ const hashedAttributes = { } ;
208+ for ( const key in attributes ) {
209+ if ( attributes . hasOwnProperty ( key ) ) {
210+ hashedAttributes [ key + '-hash' ] =
211+ 'hashed-' + attributes [ key ] ;
212+ }
213+ }
214+ window . mParticle . Rokt . hashedAttributes = hashedAttributes ;
215+ window . mParticle . Rokt . hashAttributesCalled = true ;
216+
217+ return Promise . resolve ( hashedAttributes ) ;
213218 } ,
214219 } ;
215220 } ) ;
@@ -283,6 +288,25 @@ describe('Rokt Forwarder', () => {
283288 ( result === null ) . should . equal ( true ) ;
284289 } ) ;
285290
291+ it ( 'should log an error when kit is initialized but launcher is missing' , function ( ) {
292+ var errorLogged = false ;
293+ var errorMessage = null ;
294+ window . console . error = function ( message ) {
295+ errorLogged = true ;
296+ errorMessage = message ;
297+ } ;
298+
299+ window . mParticle . forwarder . isInitialized = true ;
300+ window . mParticle . forwarder . launcher = null ;
301+
302+ window . mParticle . forwarder . hashAttributes ( {
303+ 'test-attribute' : 'test-value' ,
304+ } ) ;
305+
306+ errorLogged . should . equal ( true ) ;
307+ errorMessage . should . equal ( 'Rokt Kit: Not initialized' ) ;
308+ } ) ;
309+
286310 it ( 'should return hashed attributes from launcher' , async ( ) => {
287311 await window . mParticle . forwarder . init (
288312 {
@@ -299,7 +323,7 @@ describe('Rokt Forwarder', () => {
299323 } ) ;
300324
301325 result . should . deepEqual ( {
302- 'test-attribute' : 'hashed-value' ,
326+ 'test-attribute-hash ' : 'hashed-test -value' ,
303327 } ) ;
304328 } ) ;
305329 } ) ;
0 commit comments