Skip to content

Commit

Permalink
add test for click events
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyjhol committed Jan 30, 2021
1 parent a5f97d1 commit 8f87857
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions js/tests/unit/dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ describe('Dropdown', () => {
expect(dropdown.toggle).toHaveBeenCalled()
})

it('should allow click events to bubble', () => {
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="#">Secondary link</a>',
' </div>',
'</div>'
].join('')

const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
const clickListener = jasmine.createSpy('clickListener')

btnDropdown.addEventListener('click', () => clickListener())
btnDropdown.click()

expect(clickListener).toHaveBeenCalled()
})

it('should allow to pass config to Popper with `popperConfig`', () => {
fixtureEl.innerHTML = [
'<div class="dropdown">',
Expand Down

0 comments on commit 8f87857

Please sign in to comment.