added moar tests
Showing
1 changed file
with
14 additions
and
2 deletions
... | @@ -4,7 +4,7 @@ var casper = new phantom.Casper({ | ... | @@ -4,7 +4,7 @@ var casper = new phantom.Casper({ |
4 | faultTolerant: false, | 4 | faultTolerant: false, |
5 | verbose: true | 5 | verbose: true |
6 | }); | 6 | }); |
7 | 7 | var fs = require('fs'); | |
8 | var save = null; | 8 | var save = null; |
9 | 9 | ||
10 | phantom.args.forEach(function(arg) { | 10 | phantom.args.forEach(function(arg) { |
... | @@ -65,9 +65,20 @@ casper.then(function(self) { | ... | @@ -65,9 +65,20 @@ casper.then(function(self) { |
65 | 65 | ||
66 | casper.test.assert(casper.steps.length === 2, 'then() adds a new navigation step'); | 66 | casper.test.assert(casper.steps.length === 2, 'then() adds a new navigation step'); |
67 | 67 | ||
68 | // Casper#evaluate() | 68 | // Casper#capture() |
69 | casper.test.comment('capturing'); | ||
70 | casper.viewport(300, 200); | ||
71 | var testFile = '/tmp/__casper_test_capture.png'; | ||
72 | if (fs.isFile(testFile)) { | ||
73 | fs.remove(testFile); | ||
74 | } | ||
75 | casper.capture(testFile); | ||
76 | casper.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot'); | ||
77 | fs.remove(testFile); | ||
69 | 78 | ||
79 | // Casper#evaluate() | ||
70 | casper.then(function(self) { | 80 | casper.then(function(self) { |
81 | self.test.comment('evaluating'); | ||
71 | var params = { | 82 | var params = { |
72 | "boolean true": true, | 83 | "boolean true": true, |
73 | "boolean false": false, | 84 | "boolean false": false, |
... | @@ -84,6 +95,7 @@ casper.then(function(self) { | ... | @@ -84,6 +95,7 @@ casper.then(function(self) { |
84 | 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() exposes parameters object has the correct length'); |
85 | for (var param in casperParams) { | 96 | for (var param in casperParams) { |
86 | 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'); | ||
87 | } | 99 | } |
88 | }); | 100 | }); |
89 | 101 | ... | ... |
-
Please register or sign in to post a comment