mirror of
https://github.com/twbs/bootstrap.git
synced 2025-03-15 15:29:22 +01:00
BaseComponent: add a couple more tests (#35410)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
parent
5290080d4d
commit
3129ff075b
@ -48,6 +48,13 @@ describe('Base Component', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('NAME', () => {
|
describe('NAME', () => {
|
||||||
|
it('should throw an Error if it is not initialized', () => {
|
||||||
|
expect(() => {
|
||||||
|
// eslint-disable-next-line no-unused-expressions
|
||||||
|
BaseComponent.NAME
|
||||||
|
}).toThrowError(Error)
|
||||||
|
})
|
||||||
|
|
||||||
it('should return plugin NAME', () => {
|
it('should return plugin NAME', () => {
|
||||||
expect(DummyClass.NAME).toEqual(name)
|
expect(DummyClass.NAME).toEqual(name)
|
||||||
})
|
})
|
||||||
@ -74,6 +81,17 @@ describe('Base Component', () => {
|
|||||||
expect(elInstance._element).toEqual(el)
|
expect(elInstance._element).toEqual(el)
|
||||||
expect(selectorInstance._element).toEqual(fixtureEl.querySelector('#bar'))
|
expect(selectorInstance._element).toEqual(fixtureEl.querySelector('#bar'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not initialize and add element record to Data (caching), if argument `element` is not an HTML element', () => {
|
||||||
|
fixtureEl.innerHTML = ''
|
||||||
|
|
||||||
|
const el = fixtureEl.querySelector('#foo')
|
||||||
|
const elInstance = new DummyClass(el)
|
||||||
|
const selectorInstance = new DummyClass('#bar')
|
||||||
|
|
||||||
|
expect(elInstance._element).not.toBeDefined()
|
||||||
|
expect(selectorInstance._element).not.toBeDefined()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
describe('dispose', () => {
|
describe('dispose', () => {
|
||||||
it('should dispose an component', () => {
|
it('should dispose an component', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user