2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-05 16:42:29 +03:00

Js - use a default JQueryInterface in js components

This commit is contained in:
GeoSot
2021-12-02 18:12:53 +02:00
parent 88a6610895
commit dd9f2b31d0
27 changed files with 161 additions and 239 deletions
+34
View File
@@ -0,0 +1,34 @@
import { getJqueryInterfaceForPlugin } from '../../../src/util/jquery-stuff'
describe('Jquery Stuff', () => {
const fakejQuery = { fn: {} }
beforeEach(() => {
Object.defineProperty(window, 'jQuery', {
value: fakejQuery,
writable: true
})
})
afterEach(() => {
window.jQuery = undefined
})
describe('getJqueryInterfaceForPlugin', () => {
it('should return a plugin jQueryInterface if exists', () => {
const pluginMock = function () {}
pluginMock.NAME = 'test'
pluginMock.jQueryInterface = function () {}
expect(getJqueryInterfaceForPlugin(pluginMock)).toEqual(pluginMock.jQueryInterface)
})
it('should return the default `defaultJQueryInterface`, if plugin jQueryInterface doesn\'t exists', () => {
const pluginMock = function () {}
pluginMock.NAME = 'test'
expect(getJqueryInterfaceForPlugin(pluginMock)).not.toEqual(pluginMock.jQueryInterface)
expect(getJqueryInterfaceForPlugin(pluginMock)).toEqual(jasmine.any(Function))
})
})
})