Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Rokt-Kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,15 @@ var constructor = function () {
function isPartnerInLocalLauncherTestGroup() {
return (
window.mParticle.config &&
window.mParticle.config.isLocalLauncherEnabled
window.mParticle.config.isLocalLauncherEnabled &&
_isAssignedToSampleGroup()
);
}

function _isAssignedToSampleGroup() {
var LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD = 0.5;
return Math.random() > LOCAL_LAUNCHER_TEST_GROUP_THRESHOLD;
}
};

function generateIntegrationName(customIntegrationName) {
Expand Down
39 changes: 39 additions & 0 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ describe('Rokt Forwarder', () => {
},
};
window.mParticle.config = undefined;
Math.random = () => 1;
});

it('should create a remote launcher if the partner is not in the local launcher test group', async () => {
Expand Down Expand Up @@ -598,6 +599,44 @@ describe('Rokt Forwarder', () => {
window.mParticle.Rokt.createLocalLauncherCalled.should.equal(true);
});

it('should create a remote launcher if the partner is in the local launcher test group but the random number is below the thresholds', async () => {
window.mParticle.config = {
isLocalLauncherEnabled: true,
};

Math.random = () => 0;

await window.mParticle.forwarder.init(
{ accountId: '123456' },
reportService.cb,
true,
null,
{}
);

window.mParticle.Rokt.createLauncherCalled.should.equal(true);
window.mParticle.Rokt.createLocalLauncherCalled.should.equal(false);
});

it('should create a local launcher if the partner is in the local launcher test group but the random number is above the thresholds', async () => {
window.mParticle.config = {
isLocalLauncherEnabled: true,
};

Math.random = () => 1;

await window.mParticle.forwarder.init(
{ accountId: '123456' },
reportService.cb,
true,
null,
{}
);

window.mParticle.Rokt.createLauncherCalled.should.equal(false);
window.mParticle.Rokt.createLocalLauncherCalled.should.equal(true);
});

it('should call attachKit', async () => {
await window.mParticle.forwarder.init(
{ accountId: '123456' },
Expand Down