mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-10 15:44:51 +02:00
Refactor components to use a utility function to define jQuery plugins (#32285)
* refactor: use an utility function to define jQuery plugins * test: add spec for defineJQueryPlugin utility function * Update .bundlewatch.config.json Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -413,4 +413,29 @@ describe('Util', () => {
|
||||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
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 = function () {}
|
||||
pluginMock.jQueryInterface = function () {}
|
||||
|
||||
Util.defineJQueryPlugin('test', pluginMock)
|
||||
expect(fakejQuery.fn.test).toBe(pluginMock.jQueryInterface)
|
||||
expect(fakejQuery.fn.test.Constructor).toBe(pluginMock)
|
||||
expect(typeof fakejQuery.fn.test.noConflict).toEqual('function')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user