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:
@@ -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))
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user