added tests for FunctionArgsInjector
Showing
1 changed file
with
16 additions
and
0 deletions
... | @@ -18,6 +18,22 @@ phantom.args.forEach(function(arg) { | ... | @@ -18,6 +18,22 @@ phantom.args.forEach(function(arg) { |
18 | } | 18 | } |
19 | }); | 19 | }); |
20 | 20 | ||
21 | // phantom.Casper.FunctionArgsInjector | ||
22 | casper.test.comment('FunctionArgsInjector'); | ||
23 | function createInjector(fn, values) { | ||
24 | return new phantom.Casper.FunctionArgsInjector(fn, values); | ||
25 | } | ||
26 | var testFn = function(a, b) { return a + b; }; | ||
27 | var injector = createInjector(testFn); | ||
28 | var extract = injector.extract(testFn); | ||
29 | casper.test.assertType(extract, "object", 'FunctionArgsInjector.extract() returns an object'); | ||
30 | casper.test.assertEquals(extract.name, null, 'FunctionArgsInjector.extract() process function name as expected'); | ||
31 | casper.test.assertEquals(extract.body, 'return a + b;', 'FunctionArgsInjector.extract() process function body as expected'); | ||
32 | casper.test.assertEquals(extract.args, ['a', 'b'], 'FunctionArgsInjector.extract() process function args as expected'); | ||
33 | var processed; | ||
34 | eval('processed = ' + injector.process({ a: 1, b: 2 })); | ||
35 | casper.test.assertEquals(processed(), 3, 'FunctionArgsInjector.process() proccessed the function correctly'); | ||
36 | |||
21 | // Casper#log() | 37 | // Casper#log() |
22 | casper.test.comment('logging'); | 38 | casper.test.comment('logging'); |
23 | var oldLevel = casper.options.logLevel; | 39 | var oldLevel = casper.options.logLevel; | ... | ... |
-
Please register or sign in to post a comment