Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralpadev <2838324+alpadev@users.noreply.github.com>2020-12-08 09:16:50 +0300
committerGitHub <noreply@github.com>2020-12-08 09:16:50 +0300
commit85208ae5570aeefe4e94c1ceb29ca3b6ffdf83a1 (patch)
treeaa53633a26516f28ea292749f2389c1708ce2c44 /js/tests/unit/util
parent07b60d2c3e0744d1a3182228caa0eec42a8328b1 (diff)
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>
Diffstat (limited to 'js/tests/unit/util')
-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 ecad59b4d3..d4b09bf771 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')
+ })
+ })
})