Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test event handlers in toast dispose
  • Loading branch information
kyletsang committed Feb 8, 2021
commit 4d884cf1ae39cc62c9e7d69d4926e76af49336a9
5 changes: 5 additions & 0 deletions js/tests/unit/toast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,18 @@ describe('Toast', () => {
fixtureEl.innerHTML = '<div></div>'

const toastEl = fixtureEl.querySelector('div')
spyOn(toastEl, 'addEventListener').and.callThrough()
spyOn(toastEl, 'removeEventListener').and.callThrough()

const toast = new Toast(toastEl)

expect(Toast.getInstance(toastEl)).toBeDefined()
expect(toastEl.addEventListener).toHaveBeenCalledWith('click', jasmine.any(Function), jasmine.any(Boolean))

toast.dispose()

expect(Toast.getInstance(toastEl)).toBeNull()
expect(toastEl.removeEventListener).toHaveBeenCalledWith('click', jasmine.any(Function), jasmine.any(Boolean))
})

it('should allow to destroy toast and hide it before that', done => {
Expand Down