From 605f027c61a54ed5856f0af0563f8498f5b8d7e5 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 16 Aug 2019 18:32:16 +0100 Subject: [PATCH] Add tests for highlight tags module --- tests/javascripts/highlightTags.test.js | 449 ++++++++++++++++++++++++ 1 file changed, 449 insertions(+) create mode 100644 tests/javascripts/highlightTags.test.js diff --git a/tests/javascripts/highlightTags.test.js b/tests/javascripts/highlightTags.test.js new file mode 100644 index 000000000..cadac0b9b --- /dev/null +++ b/tests/javascripts/highlightTags.test.js @@ -0,0 +1,449 @@ +const helpers = require('./support/helpers.js'); + +beforeAll(() => { + require('../../app/assets/javascripts/highlightTags.js'); +}); + +afterAll(() => { + require('./support/teardown.js'); +}); + +describe('Highlight tags', () => { + + let input; + let textarea; + let backgroundEl; + + beforeAll(() => { + + // set some default styling + const stylesheet = document.createElement('style'); + + stylesheet.innerHTML = ".textbox-highlight-textbox { padding: 2px; width: 576px; border-width: 1px; }"; + stylesheet.innerHTML += "textarea.textbox-highlight-textbox { height: 224px; }"; + + document.getElementsByTagName('head')[0].appendChild(stylesheet); + + }); + + afterAll(() => { + + stylesheet.parentNode.removeChild(stylesheet); + + }); + + beforeEach(() => { + + // set up DOM + document.body.innerHTML = ` +
+ + +
+
+ + +
`; + + input = document.querySelector('input'); + textarea = document.querySelector('textarea'); + + }); + + afterEach(() => { + + document.body.innerHTML = ''; + + }); + + describe("When the page loads", () => { + + describe("An element should be added as a layer below the textbox to hold the highlights", () => { + + beforeEach(() => { + + // start module + window.GOVUK.modules.start(); + + }); + + test("If the textbox is a