import 'reflect-metadata'; import * as mock from './../../../mocks/index'; const initMockDocument = mock.document(jest); import { DisableScrollingService, } from './disable-scrolling.service'; const initDisableScrollingService = ( document?: Document, ) => { return new DisableScrollingService( document, ); }; describe('enableScrolling', () => { const overflowValue = ''; // tslint:disable-next-line test('It sets document.html overflow to an empty string', () => { const html = { style: { overflowY: undefined, }, }; const document = initMockDocument([html]); const disableScrollingService = initDisableScrollingService( document, ); disableScrollingService.enableScrolling(); expect(html.style.overflowY).toBe(overflowValue); }); // tslint:disable-next-line test('It sets document.body overflow to an empty string', () => { const document = initMockDocument(); const disableScrollingService = initDisableScrollingService( document, ); disableScrollingService.enableScrolling(); expect(document.body.style.overflowY).toBe(overflowValue); }); }); describe('disableScrolling', () => { const overflowValue = 'hidden'; // tslint:disable-next-line test('It sets document.html overflow to hidden', () => { const html = { style: { overflowY: undefined, }, }; const document = initMockDocument([html]); const disableScrollingService = initDisableScrollingService( document, ); disableScrollingService.disableScrolling(); expect(html.style.overflowY).toBe(overflowValue); }); // tslint:disable-next-line test('It sets document.body overflow to an empty string', () => { const document = initMockDocument(); const disableScrollingService = initDisableScrollingService( document, ); disableScrollingService.disableScrolling(); expect(document.body.style.overflowY).toBe(overflowValue); }); });