aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/util
diff options
context:
space:
mode:
authoralpadev <[email protected]>2021-05-22 09:58:52 +0200
committerGitHub <[email protected]>2021-05-22 10:58:52 +0300
commitb39b665072a2d36914e741b2c11620323924be89 (patch)
treecaaf6f2f815901efff78bdca9796fb7a46d5f785 /js/tests/unit/util
parent803397554836dcba736eb50020ed3cea07b3a3ea (diff)
downloadbootstrap-b39b665072a2d36914e741b2c11620323924be89.tar.xz
bootstrap-b39b665072a2d36914e741b2c11620323924be89.zip
Automatically select an item in the dropdown when using arrow keys (#34052)
Diffstat (limited to 'js/tests/unit/util')
-rw-r--r--js/tests/unit/util/index.spec.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js
index 774945d1f..737ecacfd 100644
--- a/js/tests/unit/util/index.spec.js
+++ b/js/tests/unit/util/index.spec.js
@@ -661,11 +661,22 @@ describe('Util', () => {
})
describe('getNextActiveElement', () => {
- it('should return first element if active not exists or not given', () => {
+ it('should return first element if active not exists or not given and shouldGetNext is either true, or false with cycling being disabled', () => {
const array = ['a', 'b', 'c', 'd']
expect(Util.getNextActiveElement(array, '', true, true)).toEqual('a')
expect(Util.getNextActiveElement(array, 'g', true, true)).toEqual('a')
+ expect(Util.getNextActiveElement(array, '', true, false)).toEqual('a')
+ expect(Util.getNextActiveElement(array, 'g', true, false)).toEqual('a')
+ expect(Util.getNextActiveElement(array, '', false, false)).toEqual('a')
+ expect(Util.getNextActiveElement(array, 'g', false, false)).toEqual('a')
+ })
+
+ it('should return last element if active not exists or not given and shouldGetNext is false but cycling is enabled', () => {
+ const array = ['a', 'b', 'c', 'd']
+
+ expect(Util.getNextActiveElement(array, '', false, true)).toEqual('d')
+ expect(Util.getNextActiveElement(array, 'g', false, true)).toEqual('d')
})
it('should return next element or same if is last', () => {