Update call out to sticky JS, with test for it

This commit is contained in:
Tom Byers
2019-05-21 13:54:45 +01:00
committed by Chris Hill-Scott
parent 0131f0c1b1
commit 1082a37750
2 changed files with 20 additions and 8 deletions

View File

@@ -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();

View File

@@ -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", () => {