diff --git a/README.md b/README.md index 674a809..118f9a9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build status](https://travis-ci.org/scm-spain/Boros-CMP.svg?branch=master)](https://travis-ci.org/scm-spain/Boros-CMP) [![codecov](https://codecov.io/gh/scm-spain/Boros-CMP/branch/master/graph/badge.svg)](https://codecov.io/gh/scm-spain/Boros-CMP) [![GitHub license](https://img.shields.io/github/license/scm-spain/Boros-CMP.svg)](https://github.com/scm-spain/Boros-CMP/blob/master/LICENSE) -[![npm version](https://img.shields.io/npm/v/@schibstedspain/boros-cmp.svg)](https://www.npmjs.com/package/@schibstedspain/boros-cmp) +[![npm version](https://img.shields.io/npm/v/@adv-ui/boros-cmp.svg)](https://www.npmjs.com/package/@adv-ui/boros-cmp) ## Table of Contents @@ -41,18 +41,18 @@ ## Usage -**Boros CMP** is available as [npm](https://www.npmjs.com/package/@schibstedspain/boros-cmp) package named **@schibstedspain/boros-cmp**. +**Boros CMP** is available as [npm](https://www.npmjs.com/package/@adv-ui/boros-cmp) package named **@adv-ui/boros-cmp**. To install the last stable version: ```bash -npm install --save @schibstedspain/boros-cmp +npm install --save @adv-ui/boros-cmp ``` To initialize Boros CMP using [default configuration](#configuration-properties-and-default-values) values: ```javascript -import boroscmp from '@schibstedspain/boros-cmp' +import boroscmp from '@adv-ui/boros-cmp' boroscmp.init() .then(()=>{ @@ -63,7 +63,7 @@ boroscmp.init() To initialize Boros CMP using customized configuration values: ```javascript -import boroscmp from '@schibstedspain/boros-cmp' +import boroscmp from '@adv-ui/boros-cmp' const customConfig = { gdpr: { @@ -84,7 +84,7 @@ boroscmp.init({config: customConfig}) Notice that **init** method is returning a _Promise_ but you can subscribe to *cmpReady* event instead: ```javascript -import boroscmp from '@schibstedspain/boros-cmp' +import boroscmp from '@adv-ui/boros-cmp' window.document.addEventListener("cmpReady", (event) => { // do your stuff ... @@ -98,7 +98,7 @@ boroscmp.init() **You could also import directly the library instead the bundled version.** By using this, it will assume you're providing the @babel/runtime dependency, helpers and polyfills needed to get it working but it will give you a better size by reusing your packages. ```javascript -import boroscmp from '@schibstedspain/boros-cmp/lib' +import boroscmp from '@adv-ui/boros-cmp/lib' boroscmp.init() .then(()=>{ @@ -110,7 +110,7 @@ boroscmp.init() Boros should be initialized with at least this custom configuration ```javascript -import boroscmp from '@schibstedspain/boros-cmp' +import boroscmp from '@adv-ui/boros-cmp' const customConfig = { gdpr: { diff --git a/package.json b/package.json index be5de8b..180f30b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "@schibstedspain/boros-cmp", + "name": "@adv-ui/boros-cmp", "version": "1.5.0", - "description": "Schibsted GDPR - Consent Management Provider - Standalone", + "description": "Adevinta GDPR - Consent Management Provider - Standalone", "main": "dist/cmp.pro.js", "scripts": { "prepack": "rm -Rf dist && rm -Rf lib && npm run build:cmp", @@ -30,6 +30,7 @@ "ads", "advertising", "schibsted", + "adevinta", "gdpr", "cmp", "consent-string", @@ -44,7 +45,7 @@ "@babel/plugin-transform-modules-commonjs": "7.2.0", "@babel/polyfill": "7.2.5", "@babel/register": "7.0.0", - "@s-ui/lint": "2", + "@s-ui/lint": "3", "babel-loader": "8.0.5", "babel-plugin-transform-define": "1.3.1", "babel-preset-sui": "3.0.0", @@ -56,7 +57,7 @@ "jsdom": "11.11.0", "mocha": "5.2.0", "sinon": "2.3.4", - "versiona": "^4.2.1", + "versiona": "4", "webpack": "4.12.0", "webpack-cli": "3.0.8", "webpack-dev-server": "3.10.1" @@ -89,5 +90,9 @@ "consent-string": "1.4.2", "isomorphic-unfetch": "3.0.0", "uuid": "3.3.2" + }, + "prettier": "./node_modules/@s-ui/lint/.prettierrc.js", + "stylelint": { + "extends": "./node_modules/@s-ui/lint/stylelint.config.js" } } diff --git a/src/cmp/application/services/consent/GetConsentStatusUseCase.js b/src/cmp/application/services/consent/GetConsentStatusUseCase.js index cf8b36f..fca3084 100644 --- a/src/cmp/application/services/consent/GetConsentStatusUseCase.js +++ b/src/cmp/application/services/consent/GetConsentStatusUseCase.js @@ -15,9 +15,8 @@ export default class GetConsentStatusUseCase { getConsentStatus() { return Promise.resolve() .then(() => this._consentRepository.getConsent()) - .then( - consent => - consent ? CONSENT_STATUS_ACCEPTED : CONSENT_STATUS_NOT_ACCEPTED + .then(consent => + consent ? CONSENT_STATUS_ACCEPTED : CONSENT_STATUS_NOT_ACCEPTED ) } } diff --git a/src/cmp/application/services/vendor_list/GetVendorListUseCase.js b/src/cmp/application/services/vendor_list/GetVendorListUseCase.js index bec054b..f51ab77 100644 --- a/src/cmp/application/services/vendor_list/GetVendorListUseCase.js +++ b/src/cmp/application/services/vendor_list/GetVendorListUseCase.js @@ -2,6 +2,7 @@ export default class GetVendorListUseCase { constructor({vendorListRepository}) { this._vendorListRepository = vendorListRepository } + /** * The result will be the GlobalVendorList being the vendor list object of the requested version. * If the vendorListVersion is null, the vendor list for the VendorListVersion in the current consent string is returned. diff --git a/src/cmp/domain/consent/UpdateConsentVendorsService.js b/src/cmp/domain/consent/UpdateConsentVendorsService.js index 9fc7049..75db4fc 100644 --- a/src/cmp/domain/consent/UpdateConsentVendorsService.js +++ b/src/cmp/domain/consent/UpdateConsentVendorsService.js @@ -68,7 +68,7 @@ export default class UpdateConsentVendorsService { newIdsNotInOldGlobalVendors ]) => { // TODO fn remove ids accepted in the consent that they are not anymore in the new global list - let newAcceptedVendorIds = acceptedVendorIds.filter( + const newAcceptedVendorIds = acceptedVendorIds.filter( id => oldIdsNotInNewGlobalVendors.indexOf(id) < 0 ) diff --git a/src/cmp/domain/vendor_consents/NewVendorsStatusService.js b/src/cmp/domain/vendor_consents/NewVendorsStatusService.js index c71eb86..899b666 100644 --- a/src/cmp/domain/vendor_consents/NewVendorsStatusService.js +++ b/src/cmp/domain/vendor_consents/NewVendorsStatusService.js @@ -9,6 +9,7 @@ class NewVendorsStatusService { constructor({option = OPTION_USE_SAME_THAN_ALL_CUSTOM_IS_TRUE} = {}) { this._option = option } + getNewVendorsStatus({acceptedVendorIds, globalVendorIds, allowedVendorIds}) { return Promise.resolve() .then(() => diff --git a/src/cmp/domain/vendor_consents/VendorConsentsFactory.js b/src/cmp/domain/vendor_consents/VendorConsentsFactory.js index 429ba1d..688123a 100644 --- a/src/cmp/domain/vendor_consents/VendorConsentsFactory.js +++ b/src/cmp/domain/vendor_consents/VendorConsentsFactory.js @@ -6,6 +6,7 @@ export default class VendorConsentsFactory { this._gdprApplies = gdprApplies this._storeConsentGlobally = storeConsentGlobally } + createVendorConsents({consent, globalVendorList, allowedVendorIds} = {}) { return Promise.resolve().then(() => Promise.all([ @@ -35,12 +36,14 @@ const filterAllowedVendorIdsFromGlobalList = ({ allowedVendorIds }) => Promise.resolve().then(() => - globalVendorList.vendors.map(v => v.id).filter(id => - isWhitelisted({ - whitelist: allowedVendorIds, - id - }) - ) + globalVendorList.vendors + .map(v => v.id) + .filter(id => + isWhitelisted({ + whitelist: allowedVendorIds, + id + }) + ) ) const createVendorConsents = ({consent, vendorIds = []} = {}) => @@ -56,11 +59,13 @@ const createVendorConsents = ({consent, vendorIds = []} = {}) => const createPurposeConsents = ({consent, globalVendorList}) => Promise.resolve().then(() => - globalVendorList.purposes.map(p => p.id).reduce( - (accumulator, id) => ({ - ...accumulator, - [`${id}`]: consent.isPurposeAllowed(id) - }), - {} - ) + globalVendorList.purposes + .map(p => p.id) + .reduce( + (accumulator, id) => ({ + ...accumulator, + [`${id}`]: consent.isPurposeAllowed(id) + }), + {} + ) ) diff --git a/src/cmp/infrastructure/bootstrap/GlobalStorageBootstrap.js b/src/cmp/infrastructure/bootstrap/GlobalStorageBootstrap.js index 0585c74..6f971a2 100644 --- a/src/cmp/infrastructure/bootstrap/GlobalStorageBootstrap.js +++ b/src/cmp/infrastructure/bootstrap/GlobalStorageBootstrap.js @@ -30,7 +30,7 @@ export default class GlobalStorageBootstrap { registerIframeCommunication(container) ]) ) - .then(([cmp, undefined]) => registerWindowCMP({cmp, window})) + .then(([cmp, any]) => registerWindowCMP({cmp, window})) .then(() => createEvent({window, name: 'cmpReady'})) } } diff --git a/src/cmp/infrastructure/build/webpack.config.babel.js b/src/cmp/infrastructure/build/webpack.config.babel.js index 8ec1658..3b47430 100644 --- a/src/cmp/infrastructure/build/webpack.config.babel.js +++ b/src/cmp/infrastructure/build/webpack.config.babel.js @@ -12,7 +12,7 @@ const getMajorVersionFromPackageJsonVersion = () => { return JSON.stringify(process.env.npm_package_version.split('.')[0]) } -let webpackConfig = { +const webpackConfig = { entry: ['@s-ui/polyfills', ENTRY_PATH], output: { path: path.resolve(OUTPUT_DIST_FOLDER), diff --git a/src/cmp/infrastructure/build/webpack.config.cmp.babel.js b/src/cmp/infrastructure/build/webpack.config.cmp.babel.js index fd4f846..f53a16c 100644 --- a/src/cmp/infrastructure/build/webpack.config.cmp.babel.js +++ b/src/cmp/infrastructure/build/webpack.config.cmp.babel.js @@ -13,7 +13,7 @@ const getMajorVersionFromPackageJsonVersion = () => { return parseInt(JSON.stringify(process.env.npm_package_version.split('.')[0])) } -let webpackConfig = { +const webpackConfig = { devtool: 'inline-source-map', entry: ENTRY_PATH, output: { diff --git a/src/cmp/infrastructure/configuration/Configuration.js b/src/cmp/infrastructure/configuration/Configuration.js index 26ef261..51f53e3 100644 --- a/src/cmp/infrastructure/configuration/Configuration.js +++ b/src/cmp/infrastructure/configuration/Configuration.js @@ -36,15 +36,19 @@ export default class Configuration { this._log = {} this._log.level = log.level || DEFAULT_LOG_LEVEL } + get gdpr() { return this._gdpr } + get vendorList() { return this._vendorList } + get consent() { return this._consent } + get log() { return this._log } diff --git a/src/cmp/infrastructure/container/BaseConsentContainer.js b/src/cmp/infrastructure/container/BaseConsentContainer.js index 89391f1..dcc879d 100644 --- a/src/cmp/infrastructure/container/BaseConsentContainer.js +++ b/src/cmp/infrastructure/container/BaseConsentContainer.js @@ -176,6 +176,7 @@ export default class BaseConsentContainer { option: this._config.consent.newVendorsStatusOption }) } + _buildGlobalVendorListVersionChangedObserver() { return globalVendorListVersionChangedObserverFactory({ updateConsentVendorsService: this.getInstance({ diff --git a/src/cmp/infrastructure/event-polyfill.js b/src/cmp/infrastructure/event-polyfill.js index d5f018d..155f2b1 100644 --- a/src/cmp/infrastructure/event-polyfill.js +++ b/src/cmp/infrastructure/event-polyfill.js @@ -5,7 +5,7 @@ if (typeof window !== 'undefined' && typeof window.CustomEvent !== 'function') { cancelable: false, detail: undefined } - let evt = document.createEvent('CustomEvent') + const evt = document.createEvent('CustomEvent') evt.initCustomEvent( event, eventParams.bubbles, diff --git a/src/cmp/infrastructure/repository/ChainedVendorListRepository.js b/src/cmp/infrastructure/repository/ChainedVendorListRepository.js index eee7266..bf8bce6 100644 --- a/src/cmp/infrastructure/repository/ChainedVendorListRepository.js +++ b/src/cmp/infrastructure/repository/ChainedVendorListRepository.js @@ -21,11 +21,12 @@ export default class ChainedVendorListRepository { .then( globalVendorList => globalVendorList || - this._getRemoteVendorList({vendorListVersion}).then( - globalVendorList => - this._saveRemoteVendorListToLocal({globalVendorList}).then( - () => globalVendorList - ) + this._getRemoteVendorList({ + vendorListVersion + }).then(globalVendorList => + this._saveRemoteVendorListToLocal({globalVendorList}).then( + () => globalVendorList + ) ) ) this._requested.set(vendorListVersion, request) diff --git a/src/cmp/infrastructure/repository/ConsentStringVendorConsentsRepository.js b/src/cmp/infrastructure/repository/ConsentStringVendorConsentsRepository.js index d3b8bd1..c8c2682 100644 --- a/src/cmp/infrastructure/repository/ConsentStringVendorConsentsRepository.js +++ b/src/cmp/infrastructure/repository/ConsentStringVendorConsentsRepository.js @@ -84,7 +84,7 @@ export default class ConsentStringVendorConsentsRepository { } _mapVendorConsentsToConsent({vendorConsents, purposeConsents}) { - let consent = new ConsentString() + const consent = new ConsentString() consent.setVendorsAllowed(vendorConsents) consent.setPurposesAllowed(purposeConsents) consent.setCmpId(this._cmpId) diff --git a/src/cmp/infrastructure/repository/HttpTranslationVendorListRepository.js b/src/cmp/infrastructure/repository/HttpTranslationVendorListRepository.js index 3ecbd65..c430bbc 100644 --- a/src/cmp/infrastructure/repository/HttpTranslationVendorListRepository.js +++ b/src/cmp/infrastructure/repository/HttpTranslationVendorListRepository.js @@ -16,11 +16,10 @@ export default class HttpTranslationVendorListRepository { return Promise.all([ this._vendorListRepository.getGlobalVendorList({vendorListVersion}), this._acceptedLanguage ? this._getTranslation({vendorListVersion}) : null - ]).then( - ([vendorList, translation]) => - translation - ? this._mergeTranslation({vendorList, translation}) - : vendorList + ]).then(([vendorList, translation]) => + translation + ? this._mergeTranslation({vendorList, translation}) + : vendorList ) } diff --git a/src/cmp/infrastructure/service/UUIDV4Generator.js b/src/cmp/infrastructure/service/UUIDV4Generator.js index 921b0cc..4c64b4d 100644 --- a/src/cmp/infrastructure/service/UUIDV4Generator.js +++ b/src/cmp/infrastructure/service/UUIDV4Generator.js @@ -5,6 +5,7 @@ export default class UUIDV4Generator { constructor({uuidv4}) { this._uuidv4 = uuidv4 } + generate() { return this._uuidv4() } diff --git a/src/cmp/infrastructure/service/iframe_communication/IframeCommunicationClient.js b/src/cmp/infrastructure/service/iframe_communication/IframeCommunicationClient.js index ee0c263..3c4c1e6 100644 --- a/src/cmp/infrastructure/service/iframe_communication/IframeCommunicationClient.js +++ b/src/cmp/infrastructure/service/iframe_communication/IframeCommunicationClient.js @@ -48,7 +48,7 @@ export default class IframeCommunicationClient { _timeout({transactionId}) { return new Promise((resolve, reject) => { - let wait = setTimeout(() => { + const wait = setTimeout(() => { clearTimeout(wait) reject(new RequestTimeoutError(transactionId)) }, POST_MESSAGE_DEFAULT_REQUEST_TIMEOUT) diff --git a/src/cmp/infrastructure/service/log/Log.js b/src/cmp/infrastructure/service/log/Log.js index 288a884..35d4b14 100644 --- a/src/cmp/infrastructure/service/log/Log.js +++ b/src/cmp/infrastructure/service/log/Log.js @@ -3,32 +3,40 @@ class Log { this._level = (this._isValidLevel({level}) && level) || LEVEL.off this._console = console || NO_CONSOLE } + changeLevel({level}) { this._level = (this._isValidLevel({level}) && level) || this._level } + get level() { return this._level } + debug(...args) { this._level <= LEVEL.debug && this._print({logMethod: this._console.log, level: 'DEBUG', args}) } + info(...args) { this._level <= LEVEL.info && this._print({logMethod: this._console.info, level: 'INFO', args}) } + warn(...args) { this._level <= LEVEL.warn && this._print({logMethod: this._console.warn, level: 'WARN', args}) } + error(...args) { this._level <= LEVEL.error && this._print({logMethod: this._console.error, level: 'ERROR', args}) } + _print({logMethod, level, args}) { const [message, ...rest] = [...args] logMethod(`[${level}] CMP - ${message}`, ...rest) } + _isValidLevel({level}) { return level >= LEVEL.debug && level <= LEVEL.off } diff --git a/src/cmp/infrastructure/service/log/loggerDebugHandler.js b/src/cmp/infrastructure/service/log/loggerDebugHandler.js index 9c0d467..4bb71ae 100644 --- a/src/cmp/infrastructure/service/log/loggerDebugHandler.js +++ b/src/cmp/infrastructure/service/log/loggerDebugHandler.js @@ -5,9 +5,7 @@ export const debugHandler = logger => ({ case 'function': return (...args) => { logger.debug( - `Function ${propKey} called from class ${ - target.constructor.name - } with arguments:`, + `Function ${propKey} called from class ${target.constructor.name} with arguments:`, Object.entries(args) ) return target[propKey].apply(target, args) diff --git a/src/globalstorage/application/globalStorage.js b/src/globalstorage/application/globalStorage.js index 554d881..b59ffc9 100644 --- a/src/globalstorage/application/globalStorage.js +++ b/src/globalstorage/application/globalStorage.js @@ -55,13 +55,10 @@ const filterEventFormatIsValid = event => const filterCommandIsValid = event => commands => Promise.resolve(event) .then(event => event.data.__cmpCall.command) - .then( - command => - typeof commands[command] === 'function' - ? command - : Promise.reject( - new CommandNotFoundError(event.data.__cmpCall.callId) - ) + .then(command => + typeof commands[command] === 'function' + ? command + : Promise.reject(new CommandNotFoundError(event.data.__cmpCall.callId)) ) const sendError = ({error, event}) => diff --git a/src/globalstorage/infrastructure/build/webpack.config.babel.js b/src/globalstorage/infrastructure/build/webpack.config.babel.js index c92d054..5e7179d 100644 --- a/src/globalstorage/infrastructure/build/webpack.config.babel.js +++ b/src/globalstorage/infrastructure/build/webpack.config.babel.js @@ -7,7 +7,7 @@ const ENTRY_PATH = './src/global.js' const OUTPUT_FILENAME_DEV = 'global.dev.js' const OUTPUT_FILENAME_PRO = 'global.pro.js' -let webpackConfig = { +const webpackConfig = { entry: ENTRY_PATH, output: { path: path.resolve(OUTPUT_DIST_FOLDER), diff --git a/src/test/cmp/domain/service/DomainEventBusTest.js b/src/test/cmp/domain/service/DomainEventBusTest.js index 5566187..5cf9949 100644 --- a/src/test/cmp/domain/service/DomainEventBusTest.js +++ b/src/test/cmp/domain/service/DomainEventBusTest.js @@ -41,7 +41,7 @@ describe('DomainEventBus test', () => { }) }) describe('Given a registered DomainEventBus', () => { - let observerSpy = sinon.spy() + const observerSpy = sinon.spy() beforeEach(function() { observerSpy.reset() }) diff --git a/src/test/cmp/infrastructure/bootstrap/TestGlobalStoreBootstrap.js b/src/test/cmp/infrastructure/bootstrap/TestGlobalStoreBootstrap.js index 12a520e..1ca2b6b 100644 --- a/src/test/cmp/infrastructure/bootstrap/TestGlobalStoreBootstrap.js +++ b/src/test/cmp/infrastructure/bootstrap/TestGlobalStoreBootstrap.js @@ -35,7 +35,7 @@ export default class TestGlobalStoreBootstrap { registerIframeCommunication(container) ]) ) - .then(([cmp, undefined]) => registerWindowCMP({cmp, window})) + .then(([cmp, any]) => registerWindowCMP({cmp, window})) } } diff --git a/src/test/cmp/infrastructure/container/TestGlobalStoreContainer.js b/src/test/cmp/infrastructure/container/TestGlobalStoreContainer.js index fa3e710..b15098d 100644 --- a/src/test/cmp/infrastructure/container/TestGlobalStoreContainer.js +++ b/src/test/cmp/infrastructure/container/TestGlobalStoreContainer.js @@ -6,6 +6,7 @@ export default class TestGlobalStoreContainer extends GlobalConsentContainer { constructor({config, window, iframe}) { super({config, window, iframe, cmpVersion: 42, eager: false}) } + _buildVendorListRepository() { return new FileVendorListRepository() } diff --git a/src/test/cmp/infrastructure/container/TestLocalStoreContainer.js b/src/test/cmp/infrastructure/container/TestLocalStoreContainer.js index 6f1b752..ea3ad59 100644 --- a/src/test/cmp/infrastructure/container/TestLocalStoreContainer.js +++ b/src/test/cmp/infrastructure/container/TestLocalStoreContainer.js @@ -6,6 +6,7 @@ export default class TestLocalStoreContainer extends LocalConsentContainer { constructor({config, window}) { super({config, window, cmpVersion: 42, eager: false}) } + _buildVendorListRepository() { return new FileVendorListRepository() } diff --git a/src/test/cmp/infrastructure/repository/ChainedVendorListRepositoryTest.js b/src/test/cmp/infrastructure/repository/ChainedVendorListRepositoryTest.js index 9a2bcbc..75722e1 100644 --- a/src/test/cmp/infrastructure/repository/ChainedVendorListRepositoryTest.js +++ b/src/test/cmp/infrastructure/repository/ChainedVendorListRepositoryTest.js @@ -83,8 +83,8 @@ describe('ChainedVendorListRepository', () => { ).to.be.equal(2) let v1 = 0 let v2 = 0 - results.forEach( - result => (result.value.vendorListVersion === 1 ? v1++ : v2++) + results.forEach(result => + result.value.vendorListVersion === 1 ? v1++ : v2++ ) expect(v1, 'should retrive 3 vendor lists of version 1').to.equal(3) expect(v2, 'should retrive 3 vendor lists of version 2').to.equal(3) diff --git a/src/test/integration/SaveNewConsentTest.js b/src/test/integration/SaveNewConsentTest.js index d51c8a2..d9b0ca7 100644 --- a/src/test/integration/SaveNewConsentTest.js +++ b/src/test/integration/SaveNewConsentTest.js @@ -93,27 +93,34 @@ const checkEncodedConsent = ({ const consent = new ConsentString(encodedConsent) // the allowed purposes into the encoded consent should be the edited purposes in the UI - globalVendorList.purposes.map(p => p.id).forEach(id => { - if (acceptedConsents.purposeConsents[id] && !consent.isPurposeAllowed(id)) { - console.log(consent.isPurposeAllowed(id)) - throw new Error(`Purpose ${id} should be allowed`) - } else if ( - !acceptedConsents.purposeConsents[id] && - consent.isPurposeAllowed(id) - ) { - throw new Error(`Purpose ${id} should not be allowed`) - } - }) + globalVendorList.purposes + .map(p => p.id) + .forEach(id => { + if ( + acceptedConsents.purposeConsents[id] && + !consent.isPurposeAllowed(id) + ) { + console.log(consent.isPurposeAllowed(id)) + throw new Error(`Purpose ${id} should be allowed`) + } else if ( + !acceptedConsents.purposeConsents[id] && + consent.isPurposeAllowed(id) + ) { + throw new Error(`Purpose ${id} should not be allowed`) + } + }) // the allowed vendors into the encoded consent should be the edited vendors in the UI - globalVendorList.vendors.map(v => v.id).forEach(id => { - if (acceptedConsents.vendorConsents[id] && !consent.isVendorAllowed(id)) { - throw new Error(`Vendor ${id} should be allowed`) - } else if ( - !acceptedConsents.vendorConsents[id] && - consent.isVendorAllowed(id) - ) { - throw new Error(`Vendor ${id} should not be allowed`) - } - }) + globalVendorList.vendors + .map(v => v.id) + .forEach(id => { + if (acceptedConsents.vendorConsents[id] && !consent.isVendorAllowed(id)) { + throw new Error(`Vendor ${id} should be allowed`) + } else if ( + !acceptedConsents.vendorConsents[id] && + consent.isVendorAllowed(id) + ) { + throw new Error(`Vendor ${id} should not be allowed`) + } + }) } diff --git a/src/test/integration/repository/FileVendorListRepository.js b/src/test/integration/repository/FileVendorListRepository.js index 0c6d90f..607e45e 100644 --- a/src/test/integration/repository/FileVendorListRepository.js +++ b/src/test/integration/repository/FileVendorListRepository.js @@ -8,6 +8,7 @@ export default class FileVendorListRepository { } = {}) { this._globalVendorListLocation = globalVendorListLocation } + getGlobalVendorList() { return Promise.resolve().then(() => require(this._globalVendorListLocation)) }