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
15ba56b2
Commit
15ba56b2
authored
Apr 17, 2016
by
David Stutz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow up on #666.
parent
f6910e40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
58 deletions
+58
-58
bootstrap-multiselect.js
tests/spec/bootstrap-multiselect.js
+58
-58
No files found.
tests/spec/bootstrap-multiselect.js
View file @
15ba56b2
...
...
@@ -706,72 +706,72 @@ describe('Bootstrap Multiselect Specific Issues', function() {
});
});
describe
(
'
Test knockout b
inding
'
,
function
()
{
var
$testArea
;
afterEach
(
function
()
{
if
(
$testArea
)
{
$testArea
.
multiselect
(
'
destroy
'
).
remove
();
}
});
describe
(
'
Knockout B
inding
'
,
function
()
{
var
$testArea
;
afterEach
(
function
()
{
if
(
$testArea
)
{
$testArea
.
multiselect
(
'
destroy
'
).
remove
();
}
});
it
(
'
s
hould update values and options with an observable array
'
,
function
()
{
jasmine
.
clock
().
install
();
it
(
'
S
hould update values and options with an observable array
'
,
function
()
{
jasmine
.
clock
().
install
();
$testArea
=
$
(
'
<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>
'
).
appendTo
(
document
.
body
);
var
viewModel
=
{
myValues
:
ko
.
observableArray
(),
myOptions
:
ko
.
observableArray
([])
};
$testArea
=
$
(
'
<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>
'
).
appendTo
(
document
.
body
);
var
viewModel
=
{
myValues
:
ko
.
observableArray
(),
myOptions
:
ko
.
observableArray
([])
};
expect
(
ko
.
bindingHandlers
.
multiselect
.
init
!==
undefined
).
toEqual
(
true
);
var
optionSpy
=
spyOn
(
ko
.
bindingHandlers
.
selectedOptions
,
'
init
'
).
and
.
callThrough
(),
multiSpy
=
spyOn
(
ko
.
bindingHandlers
.
multiselect
,
'
init
'
).
and
.
callThrough
();
expect
(
ko
.
bindingHandlers
.
multiselect
.
init
!==
undefined
).
toEqual
(
true
);
ko
.
applyBindings
(
viewModel
,
$testArea
[
0
]);
var
optionSpy
=
spyOn
(
ko
.
bindingHandlers
.
selectedOptions
,
'
init
'
).
and
.
callThrough
();
var
multiSpy
=
spyOn
(
ko
.
bindingHandlers
.
multiselect
,
'
init
'
).
and
.
callThrough
();
// knockout bindings were called
expect
(
optionSpy
.
calls
.
count
()).
toEqual
(
1
);
expect
(
multiSpy
.
calls
.
count
()).
toEqual
(
1
);
ko
.
applyBindings
(
viewModel
,
$testArea
[
0
]);
// no options are present since myOptions was empty
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
0
);
expect
(
$testArea
.
val
()).
toEqual
(
null
);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
None selected
'
);
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
0
);
// knockout bindings were called
expect
(
optionSpy
.
calls
.
count
()).
toEqual
(
1
);
expect
(
multiSpy
.
calls
.
count
()).
toEqual
(
1
);
// Add more options
viewModel
.
myOptions
([
'
option1
'
,
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
0
);
// no options are present since myOptions was empty
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
0
);
expect
(
$testArea
.
val
()).
toEqual
(
null
);
// select one
viewModel
.
myValues
([
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
1
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
text
().
trim
()).
toEqual
(
'
option2
'
);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
None selected
'
);
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
0
);
// select all
viewModel
.
myValues
([
'
option1
'
,
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
]);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
All selected (2)
'
);
// Add more options
viewModel
.
myOptions
([
'
option1
'
,
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
// add another option
viewModel
.
myOptions
.
push
(
'
wacky option
'
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
]);
expect
(
$testArea
.
find
(
'
option
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
,
'
wacky option
'
]);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
2 selected
'
);
});
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
0
);
// select one
viewModel
.
myValues
([
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
1
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
text
().
trim
()).
toEqual
(
'
option2
'
);
// select all
viewModel
.
myValues
([
'
option1
'
,
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
]);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
All selected (2)
'
);
// add another option
viewModel
.
myOptions
.
push
(
'
wacky option
'
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
2
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
]);
expect
(
$testArea
.
find
(
'
option
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
,
'
wacky option
'
]);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
2 selected
'
);
});
});
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