diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-06-06 09:26:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-06 09:26:36 +0300 |
commit | cb47b8c9640abcc19c17908475153849b9d4ad60 (patch) | |
tree | 574ef4e05facb52e35d4a939e4d69d963106a43b /js/tests/unit/modal.spec.js | |
parent | 08139c2280d60e4904f2bb7c7477f05cc3d34b1a (diff) |
Refactor scrollbar.js to be used as a Class (#33947)
Diffstat (limited to 'js/tests/unit/modal.spec.js')
-rw-r--r-- | js/tests/unit/modal.spec.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 0056e82f63..e6ef555e70 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -1,5 +1,6 @@ import Modal from '../../src/modal' import EventHandler from '../../src/dom/event-handler' +import ScrollBarHelper from '../../src/util/scrollbar' /** Test helpers */ import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture' @@ -58,25 +59,23 @@ describe('Modal', () => { }) describe('toggle', () => { - it('should toggle a modal', done => { - fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>' + it('should call ScrollBarHelper to handle scrollBar on body', done => { + fixtureEl.innerHTML = [ + '<div class="modal"><div class="modal-dialog"></div></div>' + ].join('') - const initialOverFlow = document.body.style.overflow + spyOn(ScrollBarHelper.prototype, 'hide').and.callThrough() + spyOn(ScrollBarHelper.prototype, 'reset').and.callThrough() const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) - const originalPadding = '10px' - - document.body.style.paddingRight = originalPadding modalEl.addEventListener('shown.bs.modal', () => { - expect(document.body.getAttribute('data-bs-padding-right')).toEqual(originalPadding, 'original body padding should be stored in data-bs-padding-right') - expect(document.body.style.overflow).toEqual('hidden') + expect(ScrollBarHelper.prototype.hide).toHaveBeenCalled() modal.toggle() }) modalEl.addEventListener('hidden.bs.modal', () => { - expect(document.body.getAttribute('data-bs-padding-right')).toBeNull() - expect(document.body.style.overflow).toEqual(initialOverFlow) + expect(ScrollBarHelper.prototype.reset).toHaveBeenCalled() done() }) |