Commit d8d08333 d8d083331dc4ac399fc803b3ce4bfc211c939d89 by Nicolas Perriault

refactored Casper.evaluate() in order to accept arguments!

So basically now you can do:

``` js
casper.evaluate(function(username, password) {
    document.querySelector('#username').value = username;
    document.querySelector('#password').value = password;
    document.querySelector('#submit').click();
}, {
    username: 'Bazoonga',
    password: 'baz00nga'
})
```
1 parent 4e490488
...@@ -78,7 +78,7 @@ fs.remove(testFile); ...@@ -78,7 +78,7 @@ fs.remove(testFile);
78 78
79 // Casper#evaluate() 79 // Casper#evaluate()
80 casper.then(function(self) { 80 casper.then(function(self) {
81 self.test.comment('evaluating'); 81 self.test.comment('Casper.evaluate()');
82 var params = { 82 var params = {
83 "boolean true": true, 83 "boolean true": true,
84 "boolean false": false, 84 "boolean false": false,
...@@ -92,7 +92,7 @@ casper.then(function(self) { ...@@ -92,7 +92,7 @@ casper.then(function(self) {
92 return __casper_params__; 92 return __casper_params__;
93 }, params); 93 }, params);
94 self.test.assertType(casperParams, "object", 'Casper.evaluate() exposes parameters in a dedicated object'); 94 self.test.assertType(casperParams, "object", 'Casper.evaluate() exposes parameters in a dedicated object');
95 self.test.assertEquals(Object.keys(casperParams).length, 7, 'Casper.evaluate() exposes parameters object has the correct length'); 95 self.test.assertEquals(Object.keys(casperParams).length, 7, 'Casper.evaluate() object containing parameters has the correct length');
96 for (var param in casperParams) { 96 for (var param in casperParams) {
97 self.test.assertEquals(JSON.stringify(casperParams[param]), JSON.stringify(params[param]), 'Casper.evaluate() can pass a ' + param); 97 self.test.assertEquals(JSON.stringify(casperParams[param]), JSON.stringify(params[param]), 'Casper.evaluate() can pass a ' + param);
98 self.test.assertEquals(typeof casperParams[param], typeof params[param], 'Casper.evaluate() preserves the ' + param + ' type'); 98 self.test.assertEquals(typeof casperParams[param], typeof params[param], 'Casper.evaluate() preserves the ' + param + ' type');
......