aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-10-07 15:25:00 +0300
committerGitHub <[email protected]>2022-10-07 15:25:00 +0300
commit4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33 (patch)
treee4ed791f3cfbe938308095ef1f4d123c72a323a2 /js/tests/unit
parent708a3a0e398f6c01f00283941cd6a4aca9f66322 (diff)
downloadbootstrap-4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33.tar.xz
bootstrap-4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33.zip
Boost `execute` function, being able to handle arguments (#36652)
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/util/index.spec.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js
index 9f28ce0aa..6edc49433 100644
--- a/js/tests/unit/util/index.spec.js
+++ b/js/tests/unit/util/index.spec.js
@@ -631,6 +631,25 @@ describe('Util', () => {
Util.execute(spy)
expect(spy).toHaveBeenCalled()
})
+
+ it('should execute if arg is function & return the result', () => {
+ const functionFoo = (num1, num2 = 10) => num1 + num2
+ const resultFoo = Util.execute(functionFoo, [4, 5])
+ expect(resultFoo).toBe(9)
+
+ const resultFoo1 = Util.execute(functionFoo, [4])
+ expect(resultFoo1).toBe(14)
+
+ const functionBar = () => 'foo'
+ const resultBar = Util.execute(functionBar)
+ expect(resultBar).toBe('foo')
+ })
+
+ it('should not execute if arg is not function & return default argument', () => {
+ const foo = 'bar'
+ expect(Util.execute(foo)).toBe('bar')
+ expect(Util.execute(foo, [], 4)).toBe(4)
+ })
})
describe('executeAfterTransition', () => {