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 40a206f commit 9048cf5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions js/tests/unit/dropdown.spec.js
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 create offset modifier correctly when offset option is a function', done => {
fixtureEl.innerHTML = [
'<div class="dropdown">',
Expand Down

0 comments on commit 9048cf5

Please sign in to comment.