diff options
| author | Jeremy Jackson <[email protected]> | 2021-06-29 09:45:45 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-29 17:45:45 +0300 |
| commit | d314466a4dd00006ce72f46418a98cce3cfccdb2 (patch) | |
| tree | 1ea1a0f517422ca345a43512d7554f0758548576 /js/tests | |
| parent | b00355de4b4d388dc1064ac541cf1064a7829288 (diff) | |
| download | bootstrap-d314466a4dd00006ce72f46418a98cce3cfccdb2.tar.xz bootstrap-d314466a4dd00006ce72f46418a98cce3cfccdb2.zip | |
Accept argument of different types in the `getInstance` method (#34333)
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/base-component.spec.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/js/tests/unit/base-component.spec.js b/js/tests/unit/base-component.spec.js index 1000f2841..b8ec83f12 100644 --- a/js/tests/unit/base-component.spec.js +++ b/js/tests/unit/base-component.spec.js @@ -104,6 +104,20 @@ describe('Base Component', () => { expect(DummyClass.getInstance(element)).toBeInstanceOf(DummyClass) }) + it('should accept element, either passed as a CSS selector, jQuery element, or DOM element', () => { + createInstance() + + expect(DummyClass.getInstance('#foo')).toEqual(instance) + expect(DummyClass.getInstance(element)).toEqual(instance) + + const fakejQueryObject = { + 0: element, + jquery: 'foo' + } + + expect(DummyClass.getInstance(fakejQueryObject)).toEqual(instance) + }) + it('should return null when there is no instance', () => { fixtureEl.innerHTML = '<div></div>' |
