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
c8af4268
...
c8af4268884dc35290aae007368376770174098a
authored
2011-12-09 21:29:10 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added tests for FunctionArgsInjector
1 parent
e6d651c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
tests/run.js
tests/run.js
View file @
c8af426
...
...
@@ -18,6 +18,22 @@ phantom.args.forEach(function(arg) {
}
});
// phantom.Casper.FunctionArgsInjector
casper
.
test
.
comment
(
'FunctionArgsInjector'
);
function
createInjector
(
fn
,
values
)
{
return
new
phantom
.
Casper
.
FunctionArgsInjector
(
fn
,
values
);
}
var
testFn
=
function
(
a
,
b
)
{
return
a
+
b
;
};
var
injector
=
createInjector
(
testFn
);
var
extract
=
injector
.
extract
(
testFn
);
casper
.
test
.
assertType
(
extract
,
"object"
,
'FunctionArgsInjector.extract() returns an object'
);
casper
.
test
.
assertEquals
(
extract
.
name
,
null
,
'FunctionArgsInjector.extract() process function name as expected'
);
casper
.
test
.
assertEquals
(
extract
.
body
,
'return a + b;'
,
'FunctionArgsInjector.extract() process function body as expected'
);
casper
.
test
.
assertEquals
(
extract
.
args
,
[
'a'
,
'b'
],
'FunctionArgsInjector.extract() process function args as expected'
);
var
processed
;
eval
(
'processed = '
+
injector
.
process
({
a
:
1
,
b
:
2
}));
casper
.
test
.
assertEquals
(
processed
(),
3
,
'FunctionArgsInjector.process() proccessed the function correctly'
);
// Casper#log()
casper
.
test
.
comment
(
'logging'
);
var
oldLevel
=
casper
.
options
.
logLevel
;
...
...
Please
register
or
sign in
to post a comment