mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-20 20:31:26 +02:00
create a base component
This commit is contained in:
@@ -170,4 +170,24 @@ describe('Alert', () => {
|
||||
expect(fixtureEl.querySelector('.alert')).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
it('should return alert instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const alert = new Alert(div)
|
||||
|
||||
expect(Alert.getInstance(div)).toEqual(alert)
|
||||
expect(Alert.getInstance(div) instanceof Alert).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no alert instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Alert.getInstance(div)).toEqual(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@@ -128,4 +128,24 @@ describe('Button', () => {
|
||||
expect(btnEl.classList.contains('active')).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
it('should return button instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const button = new Button(div)
|
||||
|
||||
expect(Button.getInstance(div)).toEqual(button)
|
||||
expect(Button.getInstance(div) instanceof Button).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no button instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Button.getInstance(div)).toEqual(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@@ -1062,6 +1062,26 @@ describe('Carousel', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
it('should return carousel instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const carousel = new Carousel(div)
|
||||
|
||||
expect(Carousel.getInstance(div)).toEqual(carousel)
|
||||
expect(Carousel.getInstance(div) instanceof Carousel).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no carousel instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Carousel.getInstance(div)).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('jQueryInterface', () => {
|
||||
it('should create a carousel', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
@@ -812,6 +812,7 @@ describe('Collapse', () => {
|
||||
const collapse = new Collapse(div)
|
||||
|
||||
expect(Collapse.getInstance(div)).toEqual(collapse)
|
||||
expect(Collapse.getInstance(div) instanceof Collapse).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no collapse instance', () => {
|
||||
|
@@ -1612,6 +1612,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(div)
|
||||
|
||||
expect(Dropdown.getInstance(div)).toEqual(dropdown)
|
||||
expect(Dropdown.getInstance(div) instanceof Dropdown).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no dropdown instance', () => {
|
||||
|
@@ -1108,6 +1108,7 @@ describe('Modal', () => {
|
||||
const modal = new Modal(div)
|
||||
|
||||
expect(Modal.getInstance(div)).toEqual(modal)
|
||||
expect(Modal.getInstance(div) instanceof Modal).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no modal instance', () => {
|
||||
|
@@ -253,6 +253,7 @@ describe('Popover', () => {
|
||||
const popover = new Popover(popoverEl)
|
||||
|
||||
expect(Popover.getInstance(popoverEl)).toEqual(popover)
|
||||
expect(Popover.getInstance(popoverEl) instanceof Popover).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no popover instance', () => {
|
||||
|
@@ -634,6 +634,16 @@ describe('ScrollSpy', () => {
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
it('should return scrollspy instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const scrollSpy = new ScrollSpy(div)
|
||||
|
||||
expect(ScrollSpy.getInstance(div)).toEqual(scrollSpy)
|
||||
expect(ScrollSpy.getInstance(div) instanceof ScrollSpy).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null if there is no instance', () => {
|
||||
expect(ScrollSpy.getInstance(fixtureEl)).toEqual(null)
|
||||
})
|
||||
|
@@ -417,6 +417,7 @@ describe('Tab', () => {
|
||||
const tab = new Tab(divEl)
|
||||
|
||||
expect(Tab.getInstance(divEl)).toEqual(tab)
|
||||
expect(Tab.getInstance(divEl) instanceof Tab).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
@@ -384,6 +384,7 @@ describe('Toast', () => {
|
||||
const toast = new Toast(div)
|
||||
|
||||
expect(Toast.getInstance(div)).toEqual(toast)
|
||||
expect(Toast.getInstance(div) instanceof Toast).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no toast instance', () => {
|
||||
|
@@ -1030,6 +1030,26 @@ describe('Tooltip', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
it('should return tooltip instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const alert = new Tooltip(div)
|
||||
|
||||
expect(Tooltip.getInstance(div)).toEqual(alert)
|
||||
expect(Tooltip.getInstance(div) instanceof Tooltip).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return null when there is no tooltip instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Tooltip.getInstance(div)).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('jQueryInterface', () => {
|
||||
it('should create a tooltip', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
Reference in New Issue
Block a user