aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authoralpadev <[email protected]>2020-12-08 07:16:50 +0100
committerGitHub <[email protected]>2020-12-08 08:16:50 +0200
commit85208ae5570aeefe4e94c1ceb29ca3b6ffdf83a1 (patch)
treeaa53633a26516f28ea292749f2389c1708ce2c44 /js/tests
parent07b60d2c3e0744d1a3182228caa0eec42a8328b1 (diff)
downloadbootstrap-85208ae5570aeefe4e94c1ceb29ca3b6ffdf83a1.tar.xz
bootstrap-85208ae5570aeefe4e94c1ceb29ca3b6ffdf83a1.zip
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 <[email protected]>
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/util/index.spec.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js
index ecad59b4d..d4b09bf77 100644
--- a/js/tests/unit/util/index.spec.js
+++ b/js/tests/unit/util/index.spec.js
@@ -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')
+ })
+ })
})