Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: n1k0/casperjs
...
head fork: n1k0/casperjs
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
19 tests/suites/casper/agent.js
@@ -12,15 +12,12 @@ function fetchUA(request) {
}).pop().value, /plop/);
}
-testUA(casper.options.pageSettings.userAgent, /CasperJS/);
-
-casper.start();
-
-casper.userAgent('plop').on('resource.requested', fetchUA);
-
-casper.thenOpen('tests/site/index.html');
-
-casper.run(function() {
- this.removeListener('resource.requested', fetchUA);
- this.test.done(3);
+casper.test.begin('userAgent() tests', 3, function(test) {
+ testUA(casper.options.pageSettings.userAgent, /CasperJS/);
+ casper.start();
+ casper.userAgent('plop').on('resource.requested', fetchUA);
+ casper.thenOpen('tests/site/index.html').run(function() {
+ this.removeListener('resource.requested', fetchUA);
+ test.done();
+ });
});
View
21 tests/suites/casper/alert.js
@@ -1,14 +1,13 @@
/*global casper*/
/*jshint strict:false*/
-
-var ok = false;
-
-casper.on('remote.alert', function(message) {
- ok = message === 'plop';
-});
-
-casper.start('tests/site/alert.html').run(function() {
- this.test.assert(ok, 'alert event has been intercepted');
- this.removeAllListeners('remote.alert');
- this.test.done(1);
+casper.test.begin('alert events', 1, function(test) {
+ var ok = false;
+ casper.on('remote.alert', function(message) {
+ ok = message === 'plop';
+ });
+ casper.start('tests/site/alert.html').run(function() {
+ this.test.assert(ok, 'alert event has been intercepted');
+ this.removeAllListeners('remote.alert');
+ test.done();
+ });
});
View
32 tests/suites/casper/auth.js
@@ -1,24 +1,26 @@
/*global casper*/
/*jshint strict:false maxstatements:99*/
-casper.start('tests/site/index.html');
+casper.test.begin('HTTP authentication tests', 8, function(test) {
+ casper.start('tests/site/index.html');
-casper.configureHttpAuth('http://localhost/');
-casper.test.assertEquals(casper.page.settings.userName, undefined);
-casper.test.assertEquals(casper.page.settings.password, undefined);
+ casper.configureHttpAuth('http://localhost/');
+ test.assertEquals(casper.page.settings.userName, undefined);
+ test.assertEquals(casper.page.settings.password, undefined);
-casper.configureHttpAuth('http://niko:plop@localhost/');
-casper.test.assertEquals(casper.page.settings.userName, 'niko');
-casper.test.assertEquals(casper.page.settings.password, 'plop');
+ casper.configureHttpAuth('http://niko:plop@localhost/');
+ test.assertEquals(casper.page.settings.userName, 'niko');
+ test.assertEquals(casper.page.settings.password, 'plop');
-casper.configureHttpAuth('http://localhost/', {username: 'john', password: 'doe'});
-casper.test.assertEquals(casper.page.settings.userName, 'john');
-casper.test.assertEquals(casper.page.settings.password, 'doe');
+ casper.configureHttpAuth('http://localhost/', {username: 'john', password: 'doe'});
+ test.assertEquals(casper.page.settings.userName, 'john');
+ test.assertEquals(casper.page.settings.password, 'doe');
-casper.configureHttpAuth('http://niko:plop@localhost/', {username: 'john', password: 'doe'});
-casper.test.assertEquals(casper.page.settings.userName, 'niko');
-casper.test.assertEquals(casper.page.settings.password, 'plop');
+ casper.configureHttpAuth('http://niko:plop@localhost/', {username: 'john', password: 'doe'});
+ test.assertEquals(casper.page.settings.userName, 'niko');
+ test.assertEquals(casper.page.settings.password, 'plop');
-casper.run(function() {
- this.test.done(8);
+ casper.run(function() {
+ test.done();
+ });
});
View
47 tests/suites/casper/capture.js
@@ -1,31 +1,36 @@
/*global casper*/
/*jshint strict:false*/
-var fs = require('fs'), testFile = '/tmp/__casper_test_capture.png';
+var fs = require('fs'),
+ testFile = '/tmp/__casper_test_capture.png';
if (fs.exists(testFile) && fs.isFile(testFile)) {
fs.remove(testFile);
}
-casper.start('tests/site/index.html', function() {
- this.viewport(300, 200);
- this.test.comment('Casper.capture()');
- this.capture(testFile);
- this.test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot');
+casper.test.begin('Casper.capture() tests', 1, function(test) {
+ casper.start('tests/site/index.html', function() {
+ this.viewport(300, 200);
+ this.capture(testFile);
+ test.assert(fs.isFile(testFile), 'Casper.capture() captured a screenshot');
+ }).run(function() {
+ try {
+ fs.remove(testFile);
+ } catch(e) {
+ this.warn('Unable to delete test file ' + testFile + '; please delete it manually');
+ }
+ test.done();
+ });
});
-casper.thenOpen('tests/site/index.html', function() {
- this.test.comment('Casper.captureBase64()');
- this.test.assert(this.captureBase64('png').length > 0,
- 'Casper.captureBase64() rendered a page capture as base64');
- this.test.assert(this.captureBase64('png', 'ul').length > 0,
- 'Casper.captureBase64() rendered a capture from a selector as base64');
- this.test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
- 'Casper.captureBase64() rendered a capture from a clipRect as base64');
-});
-
-casper.run(function() {
- try {
- fs.remove(testFile);
- } catch(e) {}
- this.test.done(4);
+casper.test.begin('Casper.captureBase64() tests', 3, function(test) {
+ casper.start('tests/site/index.html', function() {
+ test.assert(this.captureBase64('png').length > 0,
+ 'Casper.captureBase64() rendered a page capture as base64');
+ test.assert(this.captureBase64('png', 'ul').length > 0,
+ 'Casper.captureBase64() rendered a capture from a selector as base64');
+ test.assert(this.captureBase64('png', {top: 0, left: 0, width: 30, height: 30}).length > 0,
+ 'Casper.captureBase64() rendered a capture from a clipRect as base64');
+ }).run(function() {
+ test.done();
+ });
});

No commit comments for this range

Something went wrong with that request. Please try again.