From 0b34ff2faedb0f5f13d91d279dbe3f8b3ae1fda7 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Tue, 6 Apr 2021 18:28:10 +0300 Subject: Simplify ScrollSpy config (#33250) --- js/tests/unit/scrollspy.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/scrollspy.spec.js b/js/tests/unit/scrollspy.spec.js index f7258ba35..c4130a1aa 100644 --- a/js/tests/unit/scrollspy.spec.js +++ b/js/tests/unit/scrollspy.spec.js @@ -605,6 +605,23 @@ describe('ScrollSpy', () => { expect(ScrollSpy.getInstance(div)).toBeDefined() }) + it('should create a scrollspy with given config', () => { + fixtureEl.innerHTML = '
' + + const div = fixtureEl.querySelector('div') + + jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface + jQueryMock.elements = [div] + + jQueryMock.fn.scrollspy.call(jQueryMock, { offset: 15 }) + spyOn(ScrollSpy.prototype, 'constructor') + expect(ScrollSpy.prototype.constructor).not.toHaveBeenCalledWith(div, { offset: 15 }) + + const scrollspy = ScrollSpy.getInstance(div) + expect(scrollspy).toBeDefined() + expect(scrollspy._config.offset).toBe(15) + }) + it('should not re create a scrollspy', () => { fixtureEl.innerHTML = '
' -- cgit v1.2.3