mirror of https://github.com/twbs/bootstrap.git
Add tests
Co-authored-by: Nathan Sarang-Walters <nwalters512@gmail.com>
This commit is contained in:
parent
8fb67874c5
commit
eac65566da
|
@ -178,6 +178,58 @@ describe('Dropdown', () => {
|
|||
}))
|
||||
expect(popperConfig.placement).toEqual('left')
|
||||
})
|
||||
|
||||
it('should reflect strategy option in the constructor', () => {
|
||||
return new Promise(resolve => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
' <div class="dropdown-menu">',
|
||||
' <a class="dropdown-item" href="#">Link</a>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
|
||||
const dropdown = new Dropdown(btnDropdown, {
|
||||
strategy: 'fixed'
|
||||
})
|
||||
|
||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||
const dropdownMenu = document.querySelector('.dropdown-menu')
|
||||
expect(dropdownMenu).not.toBeNull()
|
||||
expect(dropdownMenu.computedStyleMap().get('position').value).toEqual('fixed')
|
||||
resolve()
|
||||
})
|
||||
|
||||
dropdown.toggle()
|
||||
})
|
||||
})
|
||||
|
||||
it('should reflect strategy option in data attribute', () => {
|
||||
return new Promise(resolve => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown" data-bs-strategy="fixed">Dropdown</button>',
|
||||
' <div class="dropdown-menu">',
|
||||
' <a class="dropdown-item" href="#">Link</a>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||
const dropdownMenu = document.querySelector('.dropdown-menu')
|
||||
expect(dropdownMenu).not.toBeNull()
|
||||
expect(dropdownMenu.computedStyleMap().get('position').value).toEqual('fixed')
|
||||
resolve()
|
||||
})
|
||||
|
||||
dropdown.toggle()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('toggle', () => {
|
||||
|
|
|
@ -959,6 +959,44 @@ describe('Tooltip', () => {
|
|||
tooltip.show()
|
||||
})
|
||||
})
|
||||
|
||||
it('should reflect strategy option in the constructor', () => {
|
||||
return new Promise(resolve => {
|
||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
const tooltip = new Tooltip(tooltipEl, {
|
||||
strategy: 'fixed'
|
||||
})
|
||||
|
||||
tooltipEl.addEventListener('shown.bs.tooltip', () => {
|
||||
const tip = document.querySelector('.tooltip')
|
||||
expect(tip).not.toBeNull()
|
||||
expect(tip.computedStyleMap().get('position').value).toEqual('fixed')
|
||||
resolve()
|
||||
})
|
||||
|
||||
tooltip.show()
|
||||
})
|
||||
})
|
||||
|
||||
it('should reflect strategy option in data attribute', () => {
|
||||
return new Promise(resolve => {
|
||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip" data-bs-strategy="fixed"></a>'
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
const tooltip = new Tooltip(tooltipEl)
|
||||
|
||||
tooltipEl.addEventListener('shown.bs.tooltip', () => {
|
||||
const tip = document.querySelector('.tooltip')
|
||||
expect(tip).not.toBeNull()
|
||||
expect(tip.computedStyleMap().get('position').value).toEqual('fixed')
|
||||
resolve()
|
||||
})
|
||||
|
||||
tooltip.show()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('hide', () => {
|
||||
|
|
Loading…
Reference in New Issue