Skip to content

Commit

Permalink
Testing for init function (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhisp committed Jul 13, 2022
1 parent a8bfc74 commit a54ccc5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
15 changes: 9 additions & 6 deletions modules/1plusXRtdProvider.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import { submodule } from "../src/hook"
import { submodule } from '../src/hook.js'
import { logMessage } from '../src/utils.js';

// Constants
const REAL_TIME_MODULE = 'realTimeData'
const MODULE_NAME = '1plusX'

// Functions
const getBidRequestDataAsync = async (reqBidsConfigObj, config, userConsent) => {
const getBidRequestDataAsync = (reqBidsConfigObj, config, userConsent) => {
// We don't
// Maybe treat the case where we already have the audiences & segments in local storage
// Get the required config
// Call PAPI
// -- Then :
// ---- extract relevant data
// ---- set the data to the bid
// -- Catch : print err & do nothing
// -- Catch : print err & do nothing
}

// Functions exported in submodule object
const init = (config, userConsent) => {
// We prolly get the config again in getBidRequestData
// We prolly get the config again in getBidRequestData
return true;
}

const getBidRequestData = (reqBidsConfigObj, callback, config, userConsent) => {
getBidRequestDataAsync(reqBidsConfigObj, config, userConsent)
.then(() => callback())
.catch((err) => {
console.error(err);
logMessage(err);
callback();
})
}
Expand All @@ -37,4 +40,4 @@ export const onePlusXSubmodule = {
}

// Register the onePlusXSubmodule as submodule of realTimeData
submodule(REAL_TIME_MODULE, MODULE_NAME);
submodule(REAL_TIME_MODULE, MODULE_NAME);
17 changes: 17 additions & 0 deletions test/spec/modules/1plusXRtdProvider_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { config } from 'src/config';
import { onePlusXSubmodule } from 'modules/1plusXRtdProvider';

describe('1plusXRtdProvider', () => {
before(() => {
config.resetConfig();
})

after(() => { })

describe('onePlusXSubmodule', () => {
it('init is successfull', () => {
const initResult = onePlusXSubmodule.init();
expect(initResult).to.be.true;
})
})
})

0 comments on commit a54ccc5

Please sign in to comment.