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() {
...
@@ -706,72 +706,72 @@ describe('Bootstrap Multiselect Specific Issues', function() {
});
});
});
});
describe
(
'
Test knockout b
inding
'
,
function
()
{
describe
(
'
Knockout B
inding
'
,
function
()
{
var
$testArea
;
var
$testArea
;
afterEach
(
function
()
{
afterEach
(
function
()
{
if
(
$testArea
)
{
if
(
$testArea
)
{
$testArea
.
multiselect
(
'
destroy
'
).
remove
();
$testArea
.
multiselect
(
'
destroy
'
).
remove
();
}
}
});
});
it
(
'
s
hould update values and options with an observable array
'
,
function
()
{
it
(
'
S
hould update values and options with an observable array
'
,
function
()
{
jasmine
.
clock
().
install
();
jasmine
.
clock
().
install
();
$testArea
=
$
(
'
<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>
'
).
appendTo
(
document
.
body
);
$testArea
=
$
(
'
<select multiple="multiple" data-bind="selectedOptions: myValues, options: myOptions, multiselect: {numberDisplayed: 1}"></select>
'
).
appendTo
(
document
.
body
);
var
viewModel
=
{
var
viewModel
=
{
myValues
:
ko
.
observableArray
(),
myValues
:
ko
.
observableArray
(),
myOptions
:
ko
.
observableArray
([])
myOptions
:
ko
.
observableArray
([])
};
};
expect
(
ko
.
bindingHandlers
.
multiselect
.
init
!==
undefined
).
toEqual
(
true
);
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
();
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
ko
.
applyBindings
(
viewModel
,
$testArea
[
0
]);
expect
(
optionSpy
.
calls
.
count
()).
toEqual
(
1
);
expect
(
multiSpy
.
calls
.
count
()).
toEqual
(
1
);
// no options are present since myOptions was empty
// knockout bindings were called
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
0
);
expect
(
optionSpy
.
calls
.
count
()).
toEqual
(
1
);
expect
(
$testArea
.
val
()).
toEqual
(
null
);
expect
(
multiSpy
.
calls
.
count
()).
toEqual
(
1
);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
None selected
'
);
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
0
);
// Add more options
// no options are present since myOptions was empty
viewModel
.
myOptions
([
'
option1
'
,
'
option2
'
]);
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
0
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
val
()).
toEqual
(
null
);
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
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
None selected
'
);
viewModel
.
myValues
([
'
option2
'
]);
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
0
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
1
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
text
().
trim
()).
toEqual
(
'
option2
'
);
// select all
// Add more options
viewModel
.
myValues
([
'
option1
'
,
'
option2
'
]);
viewModel
.
myOptions
([
'
option1
'
,
'
option2
'
]);
jasmine
.
clock
().
tick
(
1000
);
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
expect
(
$testArea
.
next
().
find
(
'
ul li
'
).
length
).
toEqual
(
2
);
viewModel
.
myOptions
.
push
(
'
wacky option
'
);
expect
(
$testArea
.
find
(
'
option
'
).
length
).
toEqual
(
2
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
0
);
expect
(
$testArea
.
find
(
'
option:checked
'
).
length
).
toEqual
(
2
);
// select one
expect
(
$testArea
.
find
(
'
option:checked
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
]);
viewModel
.
myValues
([
'
option2
'
]);
expect
(
$testArea
.
find
(
'
option
'
).
map
(
function
()
{
return
$
(
this
).
text
().
trim
()
}).
toArray
()).
toEqual
([
'
option1
'
,
'
option2
'
,
'
wacky option
'
]);
jasmine
.
clock
().
tick
(
1000
);
expect
(
$testArea
.
next
().
find
(
'
button.multiselect
'
).
text
().
trim
()).
toEqual
(
'
2 selected
'
);
});
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