Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
444ae972
...
444ae9720fbace8b448de0b074369d81521129d6
authored
2013-10-06 00:13:04 -0700
by
Matt DuVall
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add test coverage
1 parent
eb7e9950
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
tests/suites/utils.js
tests/suites/utils.js
View file @
444ae97
...
...
@@ -326,7 +326,7 @@ casper.test.begin('isJsFile() tests', 5, function(test) {
});
casper
.
test
.
begin
(
'mergeObjects() tests'
,
8
,
function
(
test
)
{
casper
.
test
.
begin
(
'mergeObjects() tests'
,
10
,
function
(
test
)
{
var
testCases
=
[
{
obj1
:
{
a
:
1
},
obj2
:
{
b
:
2
},
merged
:
{
a
:
1
,
b
:
2
}
...
...
@@ -360,13 +360,24 @@ casper.test.begin('mergeObjects() tests', 8, function(test) {
'mergeObjects() can merge objects'
);
});
var
obj
=
{
x
:
1
};
var
obj
=
{
x
:
1
},
qtruntimeobject
=
{
foo
:
'baz'
};
var
merged1
=
utils
.
mergeObjects
({},
{
a
:
obj
});
var
merged2
=
utils
.
mergeObjects
({
a
:
{}},
{
a
:
obj
});
merged1
.
a
.
x
=
2
;
test
.
assertEquals
(
obj
.
x
,
1
,
'mergeObjects() creates deep clones #1'
);
var
merged2
=
utils
.
mergeObjects
({
a
:
{}},
{
a
:
obj
});
merged2
.
a
.
x
=
2
;
test
.
assertEquals
(
obj
.
x
,
1
,
'mergeObjects() creates deep clones #2'
);
var
refObj
=
{
a
:
qtruntimeobject
};
var
merged3
=
utils
.
mergeObjects
({},
refObj
,
{
keepReferences
:
false
});
test
.
assertFalsy
(
merged3
.
a
==
refObj
.
a
,
'disabling references should not point to same object'
);
var
merged4
=
utils
.
mergeObjects
({},
refObj
,
{
keepReferences
:
true
});
test
.
assert
(
merged4
.
a
==
refObj
.
a
,
'enabling references should point to same object'
);
test
.
done
();
});
...
...
Please
register
or
sign in
to post a comment