From: Mark Otto Date: Sat, 31 May 2025 18:55:11 +0000 (-0700) Subject: Remove jQuery refs from JS unit test X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c49c641e0186eb196c104ffd2c6cd4454924088e;p=thirdparty%2Fbootstrap.git Remove jQuery refs from JS unit test --- diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index 9e154818f2..7fecbf7f49 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -72,18 +72,6 @@ describe('Util', () => { expect(Util.isElement({})).toBeFalse() expect(Util.isElement(fixtureEl.querySelectorAll('.test'))).toBeFalse() }) - - it('should detect jQuery element', () => { - fixtureEl.innerHTML = '
' - - const el = fixtureEl.querySelector('div') - const fakejQuery = { - 0: el, - jquery: 'foo' - } - - expect(Util.isElement(fakejQuery)).toBeTrue() - }) }) describe('getElement', () => { @@ -103,13 +91,6 @@ describe('Util', () => { expect(Util.getElement()).toBeNull() expect(Util.getElement(null)).toBeNull() expect(Util.getElement(fixtureEl.querySelectorAll('.test'))).toBeNull() - - const fakejQueryObject = { - 0: el, - jquery: 'foo' - } - - expect(Util.getElement(fakejQueryObject)).toEqual(el) }) }) @@ -425,39 +406,6 @@ describe('Util', () => { }) }) - describe('getjQuery', () => { - const fakejQuery = { trigger() {} } - - beforeEach(() => { - Object.defineProperty(window, 'jQuery', { - value: fakejQuery, - writable: true - }) - }) - - afterEach(() => { - window.jQuery = undefined - }) - - it('should return jQuery object when present', () => { - expect(Util.getjQuery()).toEqual(fakejQuery) - }) - - it('should not return jQuery object when present if data-bs-no-jquery', () => { - document.body.setAttribute('data-bs-no-jquery', '') - - expect(window.jQuery).toEqual(fakejQuery) - expect(Util.getjQuery()).toBeNull() - - document.body.removeAttribute('data-bs-no-jquery') - }) - - it('should not return jQuery if not present', () => { - window.jQuery = undefined - expect(Util.getjQuery()).toBeNull() - }) - }) - describe('onDOMContentLoaded', () => { it('should execute callbacks when DOMContentLoaded is fired and should not add more than one listener', () => { const spy = jasmine.createSpy() @@ -486,32 +434,6 @@ describe('Util', () => { }) }) - describe('defineJQueryPlugin', () => { - const fakejQuery = { fn: {} } - - beforeEach(() => { - Object.defineProperty(window, 'jQuery', { - value: fakejQuery, - writable: true - }) - }) - - afterEach(() => { - window.jQuery = undefined - }) - - it('should define a plugin on the jQuery instance', () => { - const pluginMock = Util.noop - pluginMock.NAME = 'test' - pluginMock.jQueryInterface = Util.noop - - Util.defineJQueryPlugin(pluginMock) - expect(fakejQuery.fn.test).toEqual(pluginMock.jQueryInterface) - expect(fakejQuery.fn.test.Constructor).toEqual(pluginMock) - expect(fakejQuery.fn.test.noConflict).toEqual(jasmine.any(Function)) - }) - }) - describe('execute', () => { it('should execute if arg is function', () => { const spy = jasmine.createSpy('spy')