From a9c1d643262af58ce646c89c0107a1ba81a7cedf Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 18 Sep 2020 21:51:24 +0100 Subject: [PATCH] Add tests for the focus style & new attributes --- tests/javascripts/fullscreenTable.test.js | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/javascripts/fullscreenTable.test.js b/tests/javascripts/fullscreenTable.test.js index c50c07d78..63a3c091c 100644 --- a/tests/javascripts/fullscreenTable.test.js +++ b/tests/javascripts/fullscreenTable.test.js @@ -145,6 +145,21 @@ describe('FullscreenTable', () => { }); + test("it has a role of 'region' and an accessible name matching the caption", () => { + + // start module + window.GOVUK.modules.start(); + + tableFrame = document.querySelector('.fullscreen-scrollable-table'); + caption = tableFrame.querySelector('caption'); + + expect(tableFrame.hasAttribute('role')).toBe(true); + expect(tableFrame.getAttribute('role')).toEqual('region'); + expect(tableFrame.hasAttribute('aria-labelledby')).toBe(true); + expect(tableFrame.getAttribute('aria-labelledby')).toEqual(caption.getAttribute('id')); + + }); + }); describe("the height of the table should fit the vertical space available to it", () => { @@ -317,4 +332,24 @@ describe('FullscreenTable', () => { }); + describe("when the table is focused", () => { + + beforeEach(() => { + + // start module + window.GOVUK.modules.start(); + + tableFrame = document.querySelector('.fullscreen-scrollable-table'); + tableFrame.focus(); + + }); + + test("it should make the parent frame a focus style", () => { + + expect(container.classList.contains('js-focus-style')).toBe(true); + + }); + + }); + });