Skip to content

Commit

Permalink
Fixing review comments on test to separate sharedid opt out tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skocheri committed Jun 10, 2020
1 parent 73c693d commit 6cb4d98
Showing 1 changed file with 8 additions and 91 deletions.
99 changes: 8 additions & 91 deletions test/spec/modules/userId_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ describe('User ID', function() {
}, {adUnits});
});

it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId , netId and sharedId have data to pass', function(done) {
it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, netId and sharedId have data to pass', function(done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('id5id', JSON.stringify({'ID5ID': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
Expand Down Expand Up @@ -1150,55 +1150,19 @@ describe('User ID', function() {
}, {adUnits});
});

it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId , netId and sharedId (opted out) have data to pass', function(done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('id5id', JSON.stringify({'ID5ID': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString()));
it('test hook when sharedId (opted out) have data to pass', function(done) {
coreStorage.setCookie('sharedid', JSON.stringify({'id': '00000000000000000000000000', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString()));

setSubmoduleRegistry([pubCommonIdSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, sharedIdSubmodule]);
setSubmoduleRegistry([sharedIdSubmodule]);
init(config);
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'],
['unifiedId', 'unifiedid', 'cookie'],
['id5Id', 'id5id', 'cookie'],
['identityLink', 'idl_env', 'cookie'],
['britepoolId', 'britepoolid', 'cookie'],
['netId', 'netId', 'cookie'],
['sharedId', 'sharedid', 'cookie']));
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie']));

requestBidsHook(function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
// verify that the PubCommonId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.pubcid');
expect(bid.userId.pubcid).to.equal('testpubcid');
// also check that UnifiedId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('testunifiedid');
// also check that Id5Id id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.id5id');
expect(bid.userId.id5id).to.equal('testid5id');
// check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
// also check that britepoolId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.britepoolid');
expect(bid.userId.britepoolid).to.equal('testbritepoolid');
// also check that netId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.netId');
expect(bid.userId.netId).to.equal('testnetId');
expect(bid.userIdAsEids.length).to.equal(6);
expect(bid.userIdAsEids).to.be.undefined;
});
});
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE);
done();
}, {adUnits});
Expand Down Expand Up @@ -1276,69 +1240,22 @@ describe('User ID', function() {
}, {adUnits});
});

it('test hook when pubCommonId, unifiedId, id5Id, britepoolId, netId and sharedId(opted out) have their modules added before and after init', function(done) {
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'cookie-value-add-module-variations'}), new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('id5id', JSON.stringify({'ID5ID': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', new Date(Date.now() + 5000).toUTCString());
coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString()));
coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString()));
it('test hook when sharedId(opted out) have their modules added before and after init', function(done) {
coreStorage.setCookie('sharedid', JSON.stringify({'id': '00000000000000000000000000', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString()));

setSubmoduleRegistry([]);

// attaching before init
attachIdSystem(pubCommonIdSubmodule);

init(config);

// attaching after init
attachIdSystem(unifiedIdSubmodule);
attachIdSystem(id5IdSubmodule);
attachIdSystem(identityLinkSubmodule);
attachIdSystem(britepoolIdSubmodule);
attachIdSystem(netIdSubmodule);
attachIdSystem(sharedIdSubmodule);

config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'],
['unifiedId', 'unifiedid', 'cookie'],
['id5Id', 'id5id', 'cookie'],
['identityLink', 'idl_env', 'cookie'],
['britepoolId', 'britepoolid', 'cookie'],
['netId', 'netId', 'cookie'],
['sharedId', 'sharedid', 'cookie']));
config.setConfig(getConfigMock(['sharedId', 'sharedid', 'cookie']));

requestBidsHook(function() {
adUnits.forEach(unit => {
unit.bids.forEach(bid => {
// verify that the PubCommonId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.pubcid');
expect(bid.userId.pubcid).to.equal('testpubcid');
// also check that UnifiedId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.tdid');
expect(bid.userId.tdid).to.equal('cookie-value-add-module-variations');
// also check that Id5Id id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.id5id');
expect(bid.userId.id5id).to.equal('testid5id');
// also check that identityLink id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.idl_env');
expect(bid.userId.idl_env).to.equal('AiGNC8Z5ONyZKSpIPf');
// also check that britepoolId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.britepoolid');
expect(bid.userId.britepoolid).to.equal('testbritepoolid');
// also check that britepoolId id data was copied to bid
expect(bid).to.have.deep.nested.property('userId.netId');
expect(bid.userId.netId).to.equal('testnetId');

expect(bid.userIdAsEids.length).to.equal(6);
expect(bid.userIdAsEids).to.be.undefined;
});
});
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('unifiedid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('id5id', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('idl_env', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('britepoolid', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE);
coreStorage.setCookie('sharedid', '', EXPIRED_COOKIE_DATE);
done();
}, {adUnits});
Expand Down

0 comments on commit 6cb4d98

Please sign in to comment.