Skip to content

Commit

Permalink
gppControl: accept flat section data (#12444)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Nov 16, 2024
1 parent eb130ca commit 72566c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/mspa/activityControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function mspaRule(sids, getConsent, denies, applicableSids = () => gppDat
}

function flatSection(subsections) {
if (subsections == null) return subsections;
if (!Array.isArray(subsections)) return subsections;
return subsections.reduceRight((subsection, consent) => {
return Object.assign(consent, subsection);
}, {});
Expand Down
7 changes: 7 additions & 0 deletions test/spec/libraries/mspa/activityControls_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ describe('setupRules', () => {
sinon.assert.calledWith(rules.mockActivity, {mock: 'consent'})
});

it('should accept already flattened section data', () => {
consent.parsedSections.mockApi = {flat: 'consent'};
runSetup('mockApi', [1]);
isAllowed('mockActivity', {});
sinon.assert.calledWith(rules.mockActivity, {flat: 'consent'})
})

it('should not choke when no consent data is available', () => {
consent = null;
runSetup('mockApi', [1]);
Expand Down

0 comments on commit 72566c2

Please sign in to comment.