import Alert from '../../src/alert'
import { getTransitionDurationFromElement } from '../../src/util/index'
/** Test helpers */
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
describe('Alert', () => {
let fixtureEl
beforeAll(() => {
fixtureEl = getFixture()
})
afterEach(() => {
clearFixture()
})
it('should take care of element either passed as a CSS selector or DOM element', () => {
fixtureEl.innerHTML = '
'
const alertEl = fixtureEl.querySelector('.alert')
const alertBySelector = new Alert('.alert')
const alertByElement = new Alert(alertEl)
expect(alertBySelector._element).toEqual(alertEl)
expect(alertByElement._element).toEqual(alertEl)
})
it('should return version', () => {
expect(typeof Alert.VERSION).toEqual('string')
})
describe('DATA_KEY', () => {
it('should return plugin data key', () => {
expect(Alert.DATA_KEY).toEqual('bs.alert')
})
})
describe('data-api', () => {
it('should close an alert without instantiating it manually', () => {
fixtureEl.innerHTML = [
'
',
' ',
'
'
].join('')
const button = document.querySelector('button')
button.click()
expect(document.querySelectorAll('.alert').length).toEqual(0)
})
it('should close an alert without instantiating it manually with the parent selector', () => {
fixtureEl.innerHTML = [
'