Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap-multiselect
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap-multiselect
Commits
08c7013e
Commit
08c7013e
authored
Apr 19, 2016
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more tests for collapsible optgroups.
parent
ed5ab6a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
9 deletions
+59
-9
bootstrap-multiselect.js
dist/js/bootstrap-multiselect.js
+5
-2
bootstrap-multiselect.js
tests/spec/bootstrap-multiselect.js
+54
-7
No files found.
dist/js/bootstrap-multiselect.js
View file @
08c7013e
...
@@ -267,7 +267,7 @@
...
@@ -267,7 +267,7 @@
selected
+=
label
+
delimiter
;
selected
+=
label
+
delimiter
;
});
});
return
selected
.
substr
(
0
,
selected
.
length
-
2
);
return
selected
.
substr
(
0
,
selected
.
length
-
this
.
delimiterText
.
length
);
}
}
},
},
/**
/**
...
@@ -289,7 +289,7 @@
...
@@ -289,7 +289,7 @@
var
label
=
(
$
(
this
).
attr
(
'
label
'
)
!==
undefined
)
?
$
(
this
).
attr
(
'
label
'
)
:
$
(
this
).
text
();
var
label
=
(
$
(
this
).
attr
(
'
label
'
)
!==
undefined
)
?
$
(
this
).
attr
(
'
label
'
)
:
$
(
this
).
text
();
selected
+=
label
+
delimiter
;
selected
+=
label
+
delimiter
;
});
});
return
selected
.
substr
(
0
,
selected
.
length
-
2
);
return
selected
.
substr
(
0
,
selected
.
length
-
this
.
delimiterText
.
length
);
}
}
},
},
/**
/**
...
@@ -768,6 +768,9 @@
...
@@ -768,6 +768,9 @@
// Cannot use select or deselect here because it would call updateOptGroups again.
// Cannot use select or deselect here because it would call updateOptGroups again.
this
.
options
.
onChange
(
$options
,
checked
);
this
.
options
.
onChange
(
$options
,
checked
);
this
.
updateButtonText
();
this
.
updateSelectAll
();
},
this
));
},
this
));
}
}
...
...
tests/spec/bootstrap-multiselect.js
View file @
08c7013e
...
@@ -294,6 +294,7 @@ describe('Bootstrap Multiselect "Clickable Optgroups"', function() {
...
@@ -294,6 +294,7 @@ describe('Bootstrap Multiselect "Clickable Optgroups"', function() {
$select
.
multiselect
({
$select
.
multiselect
({
buttonContainer
:
'
<div id="multiselect-container"></div>
'
,
buttonContainer
:
'
<div id="multiselect-container"></div>
'
,
enableClickableOptGroups
:
true
,
enableClickableOptGroups
:
true
,
numberDisplayed
:
10
,
onChange
:
function
(
option
,
checked
)
{
onChange
:
function
(
option
,
checked
)
{
fired
++
;
fired
++
;
}
}
...
@@ -360,6 +361,42 @@ describe('Bootstrap Multiselect "Clickable Optgroups"', function() {
...
@@ -360,6 +361,42 @@ describe('Bootstrap Multiselect "Clickable Optgroups"', function() {
});
});
});
});
it
(
'
Should update button text.
'
,
function
()
{
expect
(
$
(
'
#multiselect option:selected
'
).
length
).
toBe
(
10
);
expect
(
fired
).
toBe
(
0
);
var
i
=
0
;
$
(
'
#multiselect-container li.multiselect-group
'
).
each
(
function
()
{
if
(
i
==
0
)
{
var
text
=
''
$
(
'
option:selected
'
,
$
(
'
#multiselect optgroup
'
)[
i
]).
each
(
function
()
{
text
+=
$
(
this
).
text
()
+
'
,
'
});
text
=
text
.
substr
(
0
,
text
.
length
-
2
);
expect
(
$
(
'
#multiselect-container .multiselect-selected-text
'
).
text
()).
toBe
(
text
);
$
(
'
label
'
,
$
(
this
)).
click
()
}
else
{
$
(
'
label
'
,
$
(
this
)).
click
();
var
text
=
''
$
(
'
option:selected
'
,
$
(
'
#multiselect optgroup
'
)[
i
]).
each
(
function
()
{
text
+=
$
(
this
).
text
()
+
'
,
'
});
text
=
text
.
substr
(
0
,
text
.
length
-
2
);
expect
(
$
(
'
#multiselect-container .multiselect-selected-text
'
).
text
()).
toBe
(
text
);
$
(
'
label
'
,
$
(
this
)).
click
();
}
i
++
;
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
remove
();
$
(
'
#multiselect
'
).
remove
();
...
@@ -569,10 +606,7 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
...
@@ -569,10 +606,7 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
enableClickableOptGroups
:
true
,
enableClickableOptGroups
:
true
,
enableCollapsibleOptGroups
:
true
,
enableCollapsibleOptGroups
:
true
,
includeSelectAllOption
:
true
,
includeSelectAllOption
:
true
,
selectAllValue
:
'
multiselect-all
'
,
selectAllValue
:
'
multiselect-all
'
onChange
:
function
(
option
,
checked
)
{
fired
++
;
}
});
});
});
});
...
@@ -581,12 +615,12 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
...
@@ -581,12 +615,12 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
$
(
'
#multiselect-container li.multiselect-group .caret-container
'
).
click
();
$
(
'
#multiselect-container li.multiselect-group .caret-container
'
).
click
();
$
(
'
#multiselect-container input[value="multiselect-all"]
'
).
click
();
$
(
'
#multiselect-container input[value="multiselect-all"]
'
).
click
();
$groups
=
$
(
'
#multiselect-container li.multiselect-group
'
);
var
$groups
=
$
(
'
#multiselect-container li.multiselect-group
'
);
$groups
.
each
(
function
()
{
$groups
.
each
(
function
()
{
expect
(
$
(
this
).
hasClass
(
'
active
'
)).
toBe
(
false
);
expect
(
$
(
this
).
hasClass
(
'
active
'
)).
toBe
(
false
);
});
});
$lis
=
$
(
'
#multiselect-container li:not(.multiselect-group)
'
);
var
$lis
=
$
(
'
#multiselect-container li:not(.multiselect-group)
'
);
$lis
.
each
(
function
()
{
$lis
.
each
(
function
()
{
expect
(
$
(
this
).
hasClass
(
'
active
'
)).
toBe
(
true
);
expect
(
$
(
this
).
hasClass
(
'
active
'
)).
toBe
(
true
);
});
});
...
@@ -596,12 +630,25 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
...
@@ -596,12 +630,25 @@ describe('Bootstrap Multiselect "Clickable+Collapsible+SelectAll Optgroups"', fu
//$('#multiselect-container li.multiselect-group .caret-container').click();
//$('#multiselect-container li.multiselect-group .caret-container').click();
$
(
'
#multiselect-container input[value="multiselect-all"]
'
).
click
();
$
(
'
#multiselect-container input[value="multiselect-all"]
'
).
click
();
$lis
=
$
(
'
#multiselect-container li
'
);
var
$lis
=
$
(
'
#multiselect-container li
'
);
$lis
.
each
(
function
()
{
$lis
.
each
(
function
()
{
expect
(
$
(
'
input
'
,
this
).
prop
(
'
checked
'
)).
toBe
(
true
);
expect
(
$
(
'
input
'
,
this
).
prop
(
'
checked
'
)).
toBe
(
true
);
});
});
});
});
it
(
'
Should automatically update select all.
'
,
function
()
{
var
i
=
0
;
$
(
'
#multiselect-container li.multiselect-group
'
).
each
(
function
()
{
$
(
'
label
'
,
$
(
this
)).
click
();
expect
(
$
(
'
option:selected
'
,
$
(
'
#multiselect optgroup
'
)[
i
]).
length
).
toBe
(
10
);
expect
(
$
(
'
#multiselect option:selected
'
).
length
).
toBe
((
i
+
1
)
*
10
);
i
++
;
});
expect
(
$
(
'
#multiselect-container li input[value="multiselect-all"]
'
).
prop
(
'
checked
'
)).
toBe
(
true
);
});
afterEach
(
function
()
{
afterEach
(
function
()
{
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
multiselect
(
'
destroy
'
);
$
(
'
#multiselect
'
).
remove
();
$
(
'
#multiselect
'
).
remove
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment