migrated casper/capture tests to new testing format
Showing
1 changed file
with
21 additions
and
16 deletions
1 | /*global casper*/ | 1 | /*global casper*/ |
2 | /*jshint strict:false*/ | 2 | /*jshint strict:false*/ |
3 | var fs = require('fs'), testFile = '/tmp/__casper_test_capture.png'; | 3 | var fs = require('fs'), |
4 | testFile = '/tmp/__casper_test_capture.png'; | ||
4 | 5 | ||
5 | if (fs.exists(testFile) && fs.isFile(testFile)) { | 6 | if (fs.exists(testFile) && fs.isFile(testFile)) { |
6 | fs.remove(testFile); | 7 | fs.remove(testFile); |
7 | } | 8 | } |
8 | 9 | ||
9 | casper.start('tests/site/index.html', function() { | 10 | casper.test.begin('Casper.capture() tests', 1, function(test) { |
11 | casper.start('tests/site/index.html', function() { | ||
10 | this.viewport(300, 200); | 12 | this.viewport(300, 200); |
11 | this.test.comment('Casper.capture()'); | ||
12 | this.capture(testFile); | 13 | this.capture(testFile); |
13 | this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot'); | 14 | test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot'); |
15 | }).run(function() { | ||
16 | try { | ||
17 | fs.remove(testFile); | ||
18 | } catch(e) { | ||
19 | this.warn('Unable to delete test file ' + testFile + '; please delete it manually'); | ||
20 | } | ||
21 | test.done(); | ||
22 | }); | ||
14 | }); | 23 | }); |
15 | 24 | ||
16 | casper.thenOpen('tests/site/index.html', function() { | 25 | casper.test.begin('Casper.captureBase64() tests', 3, function(test) { |
17 | this.test.comment('Casper.captureBase64()'); | 26 | casper.start('tests/site/index.html', function() { |
18 | this.test.assert(this.captureBase64('png').length > 0, | 27 | test.assert(this.captureBase64('png').length > 0, |
19 | 'Casper.captureBase64() rendered a page capture as base64'); | 28 | 'Casper.captureBase64() rendered a page capture as base64'); |
20 | this.test.assert(this.captureBase64('png', 'ul').length > 0, | 29 | test.assert(this.captureBase64('png', 'ul').length > 0, |
21 | 'Casper.captureBase64() rendered a capture from a selector as base64'); | 30 | 'Casper.captureBase64() rendered a capture from a selector as base64'); |
22 | this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0, | 31 | test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0, |
23 | 'Casper.captureBase64() rendered a capture from a clipRect as base64'); | 32 | 'Casper.captureBase64() rendered a capture from a clipRect as base64'); |
24 | }); | 33 | }).run(function() { |
25 | 34 | test.done(); | |
26 | casper.run(function() { | 35 | }); |
27 | try { | ||
28 | fs.remove(testFile); | ||
29 | } catch(e) {} | ||
30 | this.test.done(4); | ||
31 | }); | 36 | }); | ... | ... |
-
Please register or sign in to post a comment