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
9b284cf9
authored
2012-07-14 22:42:01 +0200
by
Nicklas Ansman Giertz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add some more tests
1 parent
8739f9af
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
spec/rivets.js
spec/rivets.js
View file @
9b284cf
describe
(
'Rivets'
,
function
()
{
var
data
,
bindData
,
el
;
var
data
,
bindData
,
el
,
input
;
beforeEach
(
function
()
{
data
=
new
Data
({
foo
:
'bar'
});
bindData
=
{
data
:
data
};
el
=
document
.
createElement
(
'div'
);
input
=
document
.
createElement
(
'input'
);
input
.
setAttribute
(
'type'
,
'text'
);
rivets
.
configure
({
preloadData
:
true
,
...
...
@@ -83,6 +83,15 @@ describe('Rivets', function() {
});
});
describe
(
'Value'
,
function
()
{
it
(
'should set the value of the element'
,
function
()
{
input
.
setAttribute
(
'data-value'
,
'data.foo'
);
rivets
.
bind
(
input
,
bindData
);
expect
(
input
.
value
).
toBe
(
data
.
get
(
'foo'
));
});
});
});
describe
(
'Updates'
,
function
()
{
it
(
'should change the value'
,
function
()
{
el
.
setAttribute
(
'data-text'
,
'data.foo'
);
...
...
@@ -91,5 +100,16 @@ describe('Rivets', function() {
expect
(
el
).
toHaveTheTextContent
(
data
.
get
(
'foo'
));
});
});
describe
(
'Input'
,
function
()
{
it
(
'should update the model value'
,
function
()
{
input
.
setAttribute
(
'data-value'
,
'data.foo'
);
rivets
.
bind
(
input
,
bindData
);
input
.
value
=
'some new value'
;
var
event
=
document
.
createEvent
(
'HTMLEvents'
)
event
.
initEvent
(
'change'
,
true
,
true
);
input
.
dispatchEvent
(
event
);
expect
(
input
.
value
).
toBe
(
data
.
get
(
'foo'
));
});
});
});
...
...
Please
register
or
sign in
to post a comment