Skip to content

Commit

Permalink
Adjustment made to deps structure
Browse files Browse the repository at this point in the history
  • Loading branch information
slimkrazy committed Jan 16, 2025
1 parent af3b899 commit 8cf57ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions modules/nodalsAiRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,13 @@ class NodalsAiRtdProvider {

// eslint-disable-next-line no-dupe-class-members
#loadAdLibraries(deps) {
if (!Array.isArray(deps)) {
return;
for (const [key, value] of Object.entries(deps)) {
if (typeof value === 'string') {
loadExternalScript(value, MODULE_TYPE_RTD, MODULE_NAME, () => {
// noop
});
}
}
deps.forEach((dep) => {
loadExternalScript(dep.url, MODULE_TYPE_RTD, MODULE_NAME, () => {
// noop
});
});
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/spec/modules/nodalsAiRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const jsonResponseHeaders = {
};

const successPubEndpointResponse = {
deps: [
{version: '1.0.0', url: 'https://static.nodals.io/sdk/rule/1.0.0/engine.js'},
{version: '1.1.0', url: 'https://static.nodals.io/sdk/rule/1.1.0/engine.js'}
],
deps: {
'1.0.0': 'https://static.nodals.io/sdk/rule/1.0.0/engine.js',
'1.1.0': 'https://static.nodals.io/sdk/rule/1.1.0/engine.js'
},
facts: {
'browser.name': 'safari',
'geo.country': 'AR',
Expand Down Expand Up @@ -345,14 +345,14 @@ describe('NodalsAI RTD Provider', () => {
expect(loadExternalScriptStub.calledTwice).to.be.true;
expect(
loadExternalScriptStub.calledWith(
successPubEndpointResponse.deps[0].url,
successPubEndpointResponse.deps['1.0.0'],
MODULE_TYPE_RTD,
nodalsAiRtdSubmodule.name
)
).to.be.true;
expect(
loadExternalScriptStub.calledWith(
successPubEndpointResponse.deps[1].url,
successPubEndpointResponse.deps['1.1.0'],
MODULE_TYPE_RTD,
nodalsAiRtdSubmodule.name
)
Expand Down

0 comments on commit 8cf57ac

Please sign in to comment.