mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-16 10:34:07 +02:00
Add getOrCreateInstance
method in base-component (#33276)
Co-authored-by: Rohit Sharma <rohit2sharma95@gmail.com> Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -433,6 +433,28 @@ describe('Tab', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getOrCreateInstance', () => {
|
||||
it('should return tab instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const tab = new Tab(div)
|
||||
|
||||
expect(Tab.getOrCreateInstance(div)).toEqual(tab)
|
||||
expect(Tab.getInstance(div)).toEqual(Tab.getOrCreateInstance(div, {}))
|
||||
expect(Tab.getOrCreateInstance(div)).toBeInstanceOf(Tab)
|
||||
})
|
||||
|
||||
it('should return new instance when there is no tab instance', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
expect(Tab.getInstance(div)).toEqual(null)
|
||||
expect(Tab.getOrCreateInstance(div)).toBeInstanceOf(Tab)
|
||||
})
|
||||
})
|
||||
|
||||
describe('data-api', () => {
|
||||
it('should create dynamically a tab', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
|
Reference in New Issue
Block a user