1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-12 08:34:08 +02:00

Simplify ScrollSpy config (#33250)

This commit is contained in:
GeoSot
2021-04-06 18:28:10 +03:00
committed by GitHub
parent 4fc9386696
commit 0b34ff2fae
2 changed files with 26 additions and 12 deletions

View File

@@ -605,6 +605,23 @@ describe('ScrollSpy', () => {
expect(ScrollSpy.getInstance(div)).toBeDefined()
})
it('should create a scrollspy with given config', () => {
fixtureEl.innerHTML = '<div></div>'
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 = '<div></div>'