Skip to content

Commit

Permalink
adds support for inserter and matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Morales committed Jan 16, 2025
1 parent fd1330a commit 57123ff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
7 changes: 6 additions & 1 deletion modules/openPairIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,16 @@ export const openPairIdSubmodule = {
return {'id': ids};
},
eids: {
'openPairId': function(values) {
openPairId: function(values, config = {}) {
const inserter = config.inserter;
const matcher = config.matcher;

return [
{
source: 'pair-protocol.com',
mm: 3,
inserter: inserter,
matcher: matcher,
uids: values.map(function(value) {
return {
id: value,
Expand Down
35 changes: 32 additions & 3 deletions test/spec/modules/openPairIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
setSubmoduleRegistry
} from '../../../modules/userId/index.js';

import {createEidsArray} from '../../../modules/userId/eids.js';
import {createEidsArray, getEids} from '../../../modules/userId/eids.js';

describe('openPairId', function () {
let sandbox;
Expand Down Expand Up @@ -123,20 +123,49 @@ describe('openPairId', function () {
expect(id).to.equal(undefined)
});

describe('eids', () => {
it('honors inserter, matcher', () => {
const config = {
inserter: 'some-domain.com',
matcher: 'another-domain.com'
};

const result = openPairIdSubmodule.eids.openPairId(['some-random-id-value'], config);

expect(result.length).to.equal(1);

expect(result[0]).to.deep.equal(
{
source: 'pair-protocol.com',
mm: 3,
inserter: 'some-domain.com',
matcher: 'another-domain.com',
uids: [
{
atype: 3,
id: 'some-random-id-value'
}
]
}
);
});
});

describe('eid', () => {
before(() => {
attachIdSystem(openPairIdSubmodule);
});

it('generates the expected bid request', function() {
it('generates the minimal eids', function() {
const userId = {
openPairId: 'some-random-id-value'
};

const newEids = createEidsArray(userId);

expect(newEids.length).to.equal(1);

expect(newEids[0]).to.deep.equal({
expect(newEids[0]).to.deep.include({
source: 'pair-protocol.com',
mm: 3,
uids: [{ id: 'some-random-id-value', atype: 3 }]
Expand Down

0 comments on commit 57123ff

Please sign in to comment.