Skip to content

Commit 5ec1215

Browse files
Address PR Comments
1 parent d988568 commit 5ec1215

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"lint": "eslint src/ test/src/",
1515
"lint:fix": "eslint src/ test/src/ --fix",
1616
"watch": "rollup --config rollup.config.js -w",
17-
"watch:test": "rollup --config rollup.test.config.js -w",
17+
"watch:tests": "rollup --config rollup.test.config.js -w",
1818
"test": "npm run build && npm run build:test && karma start test/karma.config.js",
1919
"test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js"
2020
},

test/src/tests.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)