diff --git a/app/assets/javascripts/fullscreenTable.js b/app/assets/javascripts/fullscreenTable.js index 5a690022b..799e518d1 100644 --- a/app/assets/javascripts/fullscreenTable.js +++ b/app/assets/javascripts/fullscreenTable.js @@ -24,10 +24,10 @@ .on('scroll', this.maintainHeight); if ( - window.GOVUK.stopScrollingAtFooter && - window.GOVUK.stopScrollingAtFooter.updateFooterTop + window.GOVUK.stickAtBottomWhenScrolling && + window.GOVUK.stickAtBottomWhenScrolling.recalculate ) { - window.GOVUK.stopScrollingAtFooter.updateFooterTop(); + window.GOVUK.stickAtBottomWhenScrolling.recalculate(); } this.maintainWidth(); diff --git a/tests/javascripts/fullscreenTable.test.js b/tests/javascripts/fullscreenTable.test.js index 0dba9f08b..936f9027b 100644 --- a/tests/javascripts/fullscreenTable.test.js +++ b/tests/javascripts/fullscreenTable.test.js @@ -1,6 +1,9 @@ const helpers = require('./support/helpers'); beforeAll(() => { + // TODO: remove this when tests for sticky JS are written + require('../../app/assets/javascripts/stick-to-window-when-scrolling.js'); + require('../../app/assets/javascripts/fullscreenTable.js'); }); @@ -171,15 +174,11 @@ describe('FullscreenTable', () => { describe("when it loads", () => { - beforeEach(() => { + test("it fixes the number column for each row without changing the semantics", () => { // start module window.GOVUK.modules.start(); - }); - - test("it fixes the number column for each row without changing the semantics", () => { - tableFrame = document.querySelector('.fullscreen-scrollable-table'); numberColumnFrame = document.querySelector('.fullscreen-fixed-table'); @@ -189,6 +188,19 @@ describe('FullscreenTable', () => { }); + test("it calls the sticky JS to update any cached dimensions", () => { + + const stickyJSSpy = jest.spyOn(window.GOVUK.stickAtBottomWhenScrolling, 'recalculate'); + + // start module + window.GOVUK.modules.start(); + + expect(stickyJSSpy.mock.calls.length).toBe(1); + + stickyJSSpy.mockClear(); + + }); + }); describe("the height of the table should fit the vertical space available to it", () => {