Skip to content

Commit

Permalink
fixes specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Morales committed Dec 29, 2024
1 parent 4fcef12 commit ad7bd83
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/spec/modules/openPairIdSystem_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { storage, submodule } from 'modules/openPairIdSystem.js';
import { storage, openPairIdSubmodule } from 'modules/openPairIdSystem.js';
import * as utils from 'src/utils.js';

describe('openPairId', function () {
Expand All @@ -17,7 +17,7 @@ describe('openPairId', function () {
let publisherIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('habu_pairId_custom').returns(btoa(JSON.stringify({'envelope': publisherIds})));

let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
habu: {
storageKey: 'habu_pairId_custom'
Expand All @@ -35,7 +35,7 @@ describe('openPairId', function () {
let habuPublisherIds = ['habu-test-pair-id1', 'habu-test-pair-id2', 'habu-test-pair-id3'];
getDataStub.withArgs('habu_pairId_custom').returns(btoa(JSON.stringify({'envelope': habuPublisherIds})));

let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
habu: {
storageKey: 'habu_pairId_custom'
Expand All @@ -47,30 +47,30 @@ describe('openPairId', function () {
});

it('should log an error if no ID is found when getId', function() {
submodule.getId({ params: {} });
openPairIdSubmodule.getId({ params: {} });
expect(logInfoStub.calledOnce).to.be.true;
});

it('should read publisher id from local storage if exists', function() {
let publisherIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('pairId').returns(btoa(JSON.stringify(pairIds)));
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('pairId').returns(btoa(JSON.stringify(publisherIds)));

let id = submodule.getId({ params: {} });
let id = openPairIdSubmodule.getId({ params: {} });
expect(id).to.be.deep.equal({id: publisherIds});
});

it('should read publisher id from cookie if exists', function() {
let publisherIds = ['test-pair-id4', 'test-pair-id5', 'test-pair-id6'];
sandbox.stub(storage, 'getCookie').withArgs('pairId').returns(btoa(JSON.stringify(pairIds)));
sandbox.stub(storage, 'getCookie').withArgs('pairId').returns(btoa(JSON.stringify(publisherIds)));

let id = submodule.getId({ params: {} });
let id = openPairIdSubmodule.getId({ params: {} });
expect(id).to.be.deep.equal({id: publisherIds});
});

it('should read publisher id from default liveramp envelope local storage key if configured', function() {
let publisherIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('_lr_pairId').returns(btoa(JSON.stringify({'envelope': publisherIds})));
let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
liveramp: {}
}})
Expand All @@ -80,7 +80,7 @@ describe('openPairId', function () {
it('should read publisher id from default liveramp envelope cookie entry if configured', function() {
let publisherIds = ['test-pair-id4', 'test-pair-id5', 'test-pair-id6'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('_lr_pairId').returns(btoa(JSON.stringify({'envelope': publisherIds})));
let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
liveramp: {}
}})
Expand All @@ -90,7 +90,7 @@ describe('openPairId', function () {
it('should read publisher id from specified liveramp envelope cookie entry if configured with storageKey', function() {
let publisherIds = ['test-pair-id7', 'test-pair-id8', 'test-pair-id9'];
sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('lr_pairId_custom').returns(btoa(JSON.stringify({'envelope': publisherIds})));
let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
liveramp: {
storageKey: 'lr_pairId_custom'
Expand All @@ -102,7 +102,7 @@ describe('openPairId', function () {
it('should not get data from storage if local storage and cookies are disabled', function () {
sandbox.stub(storage, 'localStorageIsEnabled').returns(false);
sandbox.stub(storage, 'cookiesAreEnabled').returns(false);
let id = submodule.getId({
let id = openPairIdSubmodule.getId({
params: {
liveramp: {
storageKey: 'lr_pairId_custom'
Expand Down

0 comments on commit ad7bd83

Please sign in to comment.