diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-11-29 15:27:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 15:27:03 +0300 |
commit | 3129ff075b36e3eb59205ee2c51682fa6a29bda4 (patch) | |
tree | f0c9a8cb15dd2716644abf6132e3c7654e93f6e0 /js/tests/unit/base-component.spec.js | |
parent | 5290080d4df3047d04c8a232bca5dc7f8eaa4bc6 (diff) |
BaseComponent: add a couple more tests (#35410)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/tests/unit/base-component.spec.js')
-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 b8ec83f122..460a1b9a0e 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', () => { |