-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
164 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/cookie-banner/__tests__/google-eu-consent/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import cookieBanner from '../../src'; | ||
import defaults from '../../src/lib/defaults'; | ||
|
||
/* eslint-disable camelcase */ | ||
const init = () => { | ||
// Set up our document body | ||
document.body.innerHTML = `<main></main>`; | ||
window.__cb__ = cookieBanner({ | ||
secure: false, | ||
euConsentTypes: { | ||
ad_storage: 'test', | ||
ad_user_data: 'test', | ||
ad_personalization: 'test', | ||
analytics_storage: 'performance' | ||
}, | ||
types: { | ||
test: { | ||
title: 'Test title', | ||
description: 'Test description', | ||
labels: { | ||
yes: 'Pages you visit and actions you take will be measured and used to improve the service', | ||
no: 'Pages you visit and actions you take will not be measured and used to improve the service' | ||
}, | ||
fns: [ | ||
() => { } | ||
] | ||
}, | ||
performance: { | ||
title: 'Performance preferences', | ||
description: 'Performance cookies are used to measure the performance of our website and make improvements. Your personal data is not identified.', | ||
labels: { | ||
yes: 'Pages you visit and actions you take will be measured and used to improve the service', | ||
no: 'Pages you visit and actions you take will not be measured and used to improve the service' | ||
}, | ||
fns: [ | ||
() => { } | ||
] | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
|
||
describe(`Cookie banner > cookies > Google EU consent > default event`, () => { | ||
beforeAll(init); | ||
|
||
it('must set a default consent event with all categories denied', async () => { | ||
const banner = document.querySelector(`.${defaults.classNames.banner}`); | ||
expect(banner).not.toBeNull(); | ||
|
||
//These assertions break Jest because of the use 'arguments' in the gtag implementation | ||
//They have been manually validated in the browser | ||
// expect(window.dataLayer).toEqual([ | ||
// ['consent', 'default', { ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', analytics_storage: 'denied' }] | ||
// ]); | ||
// const acceptAllBtn = document.querySelector(`.${defaults.classNames.acceptBtn}`); | ||
// acceptAllBtn.click(); | ||
|
||
// expect(window.dataLayer).toEqual([ | ||
// ['consent', 'default', { ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', analytics_storage: 'denied' }], | ||
// ['consent', 'update', { ad_storage: 'granted', ad_user_data: 'granted', ad_personalization: 'granted', analytics_storage: 'granted' }] | ||
// ]); | ||
}); | ||
|
||
}); |
46 changes: 46 additions & 0 deletions
46
packages/cookie-banner/__tests__/google-eu-consent/no-eu-consent-config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import cookieBanner from '../../src'; | ||
import defaults from '../../src/lib/defaults'; | ||
|
||
const init = () => { | ||
// Set up our document body | ||
document.body.innerHTML = `<main></main>`; | ||
window.__cb__ = cookieBanner({ | ||
secure: false, | ||
types: { | ||
test: { | ||
title: 'Test title', | ||
description: 'Test description', | ||
labels: { | ||
yes: 'Pages you visit and actions you take will be measured and used to improve the service', | ||
no: 'Pages you visit and actions you take will not be measured and used to improve the service' | ||
}, | ||
fns: [ | ||
() => { } | ||
] | ||
}, | ||
performance: { | ||
title: 'Performance preferences', | ||
description: 'Performance cookies are used to measure the performance of our website and make improvements. Your personal data is not identified.', | ||
labels: { | ||
yes: 'Pages you visit and actions you take will be measured and used to improve the service', | ||
no: 'Pages you visit and actions you take will not be measured and used to improve the service' | ||
}, | ||
fns: [ | ||
() => { } | ||
] | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
|
||
describe(`Cookie banner > cookies > Google EU consent > no EU consent settings`, () => { | ||
beforeAll(init); | ||
|
||
it('No errors or pushes to dataLayer if no consent options configured', async () => { | ||
const banner = document.querySelector(`.${defaults.classNames.banner}`); | ||
expect(banner).not.toBeNull(); | ||
expect(window.dataLayer).toBeUndefined(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters