Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets-backbone-adapter-brainfood
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
c4e53ec5
authored
2016-06-07 11:07:04 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
More testing on full-object returns through the adapter.
1 parent
e4adb2bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
5 deletions
src/scripts/rivets-backbone-adapter-brainfood.spec.js
src/scripts/rivets-backbone-adapter-brainfood.spec.js
View file @
c4e53ec
...
...
@@ -49,8 +49,25 @@ define(function(require) {
function
buildTest
(
path
,
options
)
{
it
(
path
,
function
()
{
var
inputElement
=
document
.
createElement
(
'input'
);
inputElement
.
setAttribute
(
'rv-value'
,
path
);
var
binderName
=
options
.
bb
?
'bb-model'
:
'value'
;
inputElement
.
setAttribute
(
'rv-'
+
binderName
,
path
);
var
pojoObjects
=
[];
var
view
=
rivets
.
bind
(
inputElement
,
model
,
{
binders
:
{
'bb-model'
:
{
bind
:
function
(
el
)
{
console
.
log
(
'bb-model:bind'
,
el
);
},
routine
:
function
(
el
,
value
)
{
var
pojoObject
=
options
.
parse
(
value
);
console
.
log
(
'bb-model:routine'
,
el
,
JSON
.
stringify
(
pojoObject
));
pojoObjects
.
push
(
pojoObject
);
},
unbind
:
function
(
el
)
{
console
.
log
(
'bb-model:unbind'
,
el
);
},
},
},
formatters
:
{
toJSON
:
function
(
value
)
{
return
value
.
toJSON
();
...
...
@@ -80,7 +97,11 @@ define(function(require) {
}
}
var
value
=
convertValue
(
options
.
value
);
if
(
options
.
bb
)
{
expect
(
pojoObjects
[
0
]).
toEqual
(
value
);
}
else
{
expect
(
getInputElementValue
()).
toEqual
(
value
);
}
if
(
options
.
get
)
{
var
newValue
=
convertValue
(
options
.
newValue
);
inputElement
.
value
=
newValue
;
...
...
@@ -118,13 +139,40 @@ define(function(require) {
value
:
''
,
});
//buildTest(':contactMechs:*.length', '2');
buildTest
(
':contactMechs:PRIMARY_EMAIL | toJSON | jsonStringify'
,
{
buildTest
(
':contactMechs:PRIMARY_EMAIL'
,
{
bb
:
true
,
value
:
function
()
{
var
primaryEmail
=
contactMechs
.
get
(
'PRIMARY_EMAIL'
);
return
primaryEmail
.
toJSON
();
return
contactMechs
.
get
(
'PRIMARY_EMAIL'
).
toJSON
();
},
parse
:
function
(
rawValue
)
{
return
JSON
.
parse
(
rawValue
);
return
rawValue
.
toJSON
();
},
});
buildTest
(
':contactMechs:PRIMARY_EMAIL:*'
,
{
bb
:
true
,
value
:
function
()
{
return
contactMechs
.
get
(
'PRIMARY_EMAIL'
).
toJSON
();
},
parse
:
function
(
rawValue
)
{
return
rawValue
;
},
});
buildTest
(
':contactMechs'
,
{
bb
:
true
,
value
:
function
()
{
return
contactMechs
.
toJSON
();
},
parse
:
function
(
rawValue
)
{
return
rawValue
.
toJSON
();
},
});
buildTest
(
':contactMechs:*'
,
{
bb
:
true
,
value
:
function
()
{
return
contactMechs
.
models
;
},
parse
:
function
(
rawValue
)
{
return
rawValue
;
},
});
/*
...
...
Please
register
or
sign in
to post a comment