]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Remove jQuery refs from JS unit test
authorMark Otto <markdotto@gmail.com>
Sat, 31 May 2025 18:55:11 +0000 (11:55 -0700)
committerMark Otto <markdotto@gmail.com>
Sat, 31 May 2025 18:55:11 +0000 (11:55 -0700)
js/tests/unit/util/index.spec.js

index 9e154818f288770180653bbd033b96fed33b40d0..7fecbf7f49471bc5c2882982484f0e58e5e51d07 100644 (file)
@@ -72,18 +72,6 @@ describe('Util', () => {
       expect(Util.isElement({})).toBeFalse()
       expect(Util.isElement(fixtureEl.querySelectorAll('.test'))).toBeFalse()
     })
-
-    it('should detect jQuery element', () => {
-      fixtureEl.innerHTML = '<div></div>'
-
-      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')