Add JS tests for analytics & cookies JS

Includes:
- tests for the analytics interface ported from
  GOVUK Frontend Toolkit
- tests for the cookie banner that appears on all
  pages except the cookies page
- tests for the cookies page JS
- tests for the hasConsentFor function
- adding a deleteCookie helper to remove
  cookies during tests
- polyfill for insertAdjacentText

The last one is because JSDOM doesn't support
insertAdjacentText but our target browsers
do. This polyfill also includes one for
insertAdjacentHTML.
This commit is contained in:
Tom Byers
2019-12-31 16:49:52 +00:00
parent beeb273d6c
commit 900aa19bd3
9 changed files with 841 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
const globals = require('./helpers/globals.js');
const events = require('./helpers/events.js');
const domInterfaces = require('./helpers/dom_interfaces.js');
const cookies = require('./helpers/cookies.js');
const html = require('./helpers/html.js');
const elements = require('./helpers/elements.js');
const rendering = require('./helpers/rendering.js');
@@ -14,6 +15,8 @@ exports.moveSelectionToRadio = events.moveSelectionToRadio;
exports.activateRadioWithSpace = events.activateRadioWithSpace;
exports.RangeMock = domInterfaces.RangeMock;
exports.SelectionMock = domInterfaces.SelectionMock;
exports.deleteCookie = cookies.deleteCookie;
exports.setCookie = cookies.setCookie;
exports.getRadioGroup = html.getRadioGroup;
exports.getRadios = html.getRadios;
exports.templatesAndFoldersCheckboxes = html.templatesAndFoldersCheckboxes;