Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4a9ade49
authored
2012-07-29 17:19:57 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add specs for Rivets.Binding::bind() including edge cases for preloadData and bypass.
1 parent
0e79195d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
spec/rivets/binding.js
spec/rivets/binding.js
View file @
4a9ade4
...
...
@@ -21,6 +21,41 @@ describe('Rivets.Binding', function() {
expect
(
binding
.
routine
).
toBe
(
rivets
.
routines
.
text
);
});
describe
(
'bind()'
,
function
()
{
it
(
'subscribes to the model for changes via the adapter'
,
function
()
{
spyOn
(
rivets
.
config
.
adapter
,
'subscribe'
);
binding
.
bind
();
expect
(
rivets
.
config
.
adapter
.
subscribe
).
toHaveBeenCalled
();
});
describe
(
'with preloadData set to true'
,
function
()
{
beforeEach
(
function
()
{
rivets
.
config
.
preloadData
=
true
;
});
it
(
'sets the initial value via the adapter'
,
function
()
{
spyOn
(
binding
,
'set'
);
spyOn
(
rivets
.
config
.
adapter
,
'read'
);
binding
.
bind
();
expect
(
binding
.
set
).
toHaveBeenCalled
();
expect
(
rivets
.
config
.
adapter
.
read
).
toHaveBeenCalled
();
});
});
describe
(
'with the bypass option set to true'
,
function
()
{
beforeEach
(
function
()
{
binding
.
options
.
bypass
=
true
;
});
it
(
'sets the initial value from the model directly'
,
function
()
{
spyOn
(
binding
,
'set'
);
binding
.
model
.
name
=
'espresso'
;
binding
.
bind
();
expect
(
binding
.
set
).
toHaveBeenCalledWith
(
'espresso'
);
});
});
});
describe
(
'set()'
,
function
()
{
it
(
'performs the binding routine with the supplied value'
,
function
()
{
spyOn
(
binding
,
'routine'
);
...
...
Please
register
or
sign in
to post a comment