mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-06 21:56:42 +02:00
Remove jQuery refs from JS unit test
This commit is contained in:
@@ -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')
|
||||
|
Reference in New Issue
Block a user