diff options
| author | Rohit Sharma <[email protected]> | 2020-12-16 20:07:27 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2021-01-28 12:23:33 +0200 |
| commit | b1bd54955ed5d6cd3eeb848dd068fc8bca88d585 (patch) | |
| tree | cc5c4caa190a618508d0fabb8df8dc87bee185bc /js/tests | |
| parent | 881f43a3b928e792185ed388e2589c73ea8c4be6 (diff) | |
| download | bootstrap-b1bd54955ed5d6cd3eeb848dd068fc8bca88d585.tar.xz bootstrap-b1bd54955ed5d6cd3eeb848dd068fc8bca88d585.zip | |
Restore `offset` option for tooltip/popover components
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/tooltip.spec.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.spec.js b/js/tests/unit/tooltip.spec.js index 213dcc91f..38af0235b 100644 --- a/js/tests/unit/tooltip.spec.js +++ b/js/tests/unit/tooltip.spec.js @@ -107,6 +107,41 @@ describe('Tooltip', () => { tooltipInContainerEl.click() }) + it('should create offset modifier when offset is passed as a function', done => { + fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Offset from function">' + + const getOffset = jasmine.createSpy('getOffset').and.returnValue([10, 20]) + const tooltipEl = fixtureEl.querySelector('a') + const tooltip = new Tooltip(tooltipEl, { + offset: getOffset, + popperConfig: { + onFirstUpdate: state => { + expect(getOffset).toHaveBeenCalledWith({ + popper: state.rects.popper, + reference: state.rects.reference, + placement: state.placement + }, tooltipEl) + done() + } + } + }) + + const offset = tooltip._getOffset() + + expect(typeof offset).toEqual('function') + + tooltip.show() + }) + + it('should create offset modifier when offset option is passed in data attribute', () => { + fixtureEl.innerHTML = '<a href="#" rel="tooltip" data-bs-offset="10,20" title="Another tooltip">' + + const tooltipEl = fixtureEl.querySelector('a') + const tooltip = new Tooltip(tooltipEl) + + expect(tooltip._getOffset()).toEqual([10, 20]) + }) + it('should allow to pass config to Popper with `popperConfig`', () => { fixtureEl.innerHTML = '<a href="#" rel="tooltip">' |
