diff options
| author | GeoSot <[email protected]> | 2021-11-29 14:27:03 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-29 14:27:03 +0200 |
| commit | 3129ff075b36e3eb59205ee2c51682fa6a29bda4 (patch) | |
| tree | f0c9a8cb15dd2716644abf6132e3c7654e93f6e0 | |
| parent | 5290080d4df3047d04c8a232bca5dc7f8eaa4bc6 (diff) | |
| download | bootstrap-3129ff075b36e3eb59205ee2c51682fa6a29bda4.tar.xz bootstrap-3129ff075b36e3eb59205ee2c51682fa6a29bda4.zip | |
BaseComponent: add a couple more tests (#35410)
Co-authored-by: XhmikosR <[email protected]>
| -rw-r--r-- | js/tests/unit/base-component.spec.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/tests/unit/base-component.spec.js b/js/tests/unit/base-component.spec.js index b8ec83f12..460a1b9a0 100644 --- a/js/tests/unit/base-component.spec.js +++ b/js/tests/unit/base-component.spec.js @@ -48,6 +48,13 @@ describe('Base Component', () => { }) 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', () => { expect(DummyClass.NAME).toEqual(name) }) @@ -74,6 +81,17 @@ describe('Base Component', () => { expect(elInstance._element).toEqual(el) 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', () => { it('should dispose an component', () => { |
